Commit c861cd3d authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Fixed NaN OBM buildings in GDEProcessor.process_group_data_unit_tiles()

parent 131edb30
Pipeline #41419 passed with stage
in 2 minutes and 12 seconds
......@@ -781,6 +781,7 @@ class GDEProcessor:
# aggregated and OBM buildings per data-unit tiles in the same DataFrame
data_unit_tiles_full = data_unit_tiles.join(obm_buildings_per_quadkey.counts, "quadkey")
data_unit_tiles_full = data_unit_tiles_full.rename(columns={"counts": "obm_buildings"})
data_unit_tiles_full["obm_buildings"] = data_unit_tiles_full["obm_buildings"].fillna(0)
# Prepare 'data_unit_tiles' for parallel processing:
# each tuple contains (quadkey, aggregated_buildings, obm_buildings) of a data-unit tile
......
......@@ -209,4 +209,6 @@ CREATE TABLE obm_built_area_assessments
INSERT INTO obm_built_area_assessments(quadkey, source_id, completeness)
VALUES ('122010321033023130', 1, 0),
('122010321033023120', 1, 0),
('122010321033023132', 1, 1);
('122010321033023132', 1, 1),
('122010321033023121', 1, 0),
('122010321033023123', 1, 1);
......@@ -480,8 +480,14 @@ def test_process_group_data_unit_tiles(test_db):
data_unit_tiles = pandas.DataFrame(
{
"quadkey": ["122010321033023120", "122010321033023132", "122010321033023130"],
"aggregated_buildings": [39.1, 34.4, 15.7],
"quadkey": [
"122010321033023120",
"122010321033023132",
"122010321033023130",
"122010321033023121",
"122010321033023123",
],
"aggregated_buildings": [39.1, 34.4, 15.7, 26.2, 16.5],
}
)
......@@ -497,8 +503,10 @@ def test_process_group_data_unit_tiles(test_db):
expected_output["122010321033023130"] = (12.7, False)
expected_output["122010321033023120"] = (0.0, False)
expected_output["122010321033023132"] = (0.0, True)
expected_output["122010321033023121"] = (26.2, False)
expected_output["122010321033023123"] = (0.0, True)
assert returned_data_unit_tiles_full.shape[0] == 3
assert returned_data_unit_tiles_full.shape[0] == 5
for quadkey in expected_output.keys():
assert (
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment