Skip to content

Added feature to export to GeoSummary format

Cecilia Nievas requested to merge feature/export_tile_geosummary into main

This MR:

  • adds the capability to export the GDE model to what is being called a "GeoSummary" format; the output consists of a GeoPackage (.gpkg) file that summarises relevant values per quadtile;
  • fixes an issue of compatibility of geometry types to append to GPKG that arose in the functionality to export to OpenQuake while testing this new feature.

Details on the capability to export the GDE model to the "GeoSummary" format:

The output GeoPackage (.gpkg) file has name pattern [quadkeys_group]_[occupancy_case]_geosummary_tiles.gpkg and contains the following fields:

  • quadkey (str): Quadkey of the tile.
  • geometry (geometry): Geometry of the tile.
  • [occupancy_case]_number_data_units: Number of data units associated with this quadtile and occupancy case.
  • [occupancy_case]_[building_type]_buildings: Number of buildings in the tile of the type building_type (each of the elements of buildings_to_export specified in the configuration file) and of occupancy_case.
  • [occupancy_case]_[building_type]_XXX: Fields in which occupancy_case and building_type have the same meaning as above, and XXX refers to:
    • Columns associated with building replacement costs, whose name and contents are user-defined (cost_cases specified in the configuration file).
    • Columns associated with the number of people in the building at different times of the day, whose names and contents are user-defined (people_cases specified in the configuration file). In all of the cost- and people-cases columns, the values stored correspond to the sum of all buildings in the tile of the corresponding occupancy_case and building_type ([occupancy_case]_[building_type]_buildings field).

Details on the issue of compatibility of geometry types to append to GPKG:

When appending to a GPKG file, the geometry types of the existing file and the data to be appended need to be the same. While trying out the code I encountered cases of OBM buildings whose geometries are defined as MultiPolygons instead of Polygons. If the GPKG file is first created first with only Polygon geometries, then geopandas throws an error when trying to append MultiPolygon geometries. This was addressed by converting all OBM footprints to MultiPolygons when retrieving data using DatabaseQueries.get_GDE_buildings. It was done there because that method was already looping through OSM IDs, while adding this check elsewhere would make the code loop again.

Merge request reports

Loading