Skip to content
Snippets Groups Projects

Resolve "Add height from GHSL characteristics"

Merged Laurens Oostwegel requested to merge 18-add-height-from-ghsl-characteristics into main
@@ -21,7 +21,7 @@ class GHSLCharacteristicsInformation:
def __call__(self, database, geometry_wkt, *args, **kwargs):
"""
Intersect the building geometry with the GHSL characteristics layer and return the type
with the most overlap.
with the largest overlap.
Args:
database (PostGISDatabase):
@@ -30,7 +30,8 @@ class GHSLCharacteristicsInformation:
The WKT representation of the geometry of the building.
Returns:
A dictionary with the most overlapping GHSL characteristics type.
A dictionary with the GHSL characteristics type exhibiting the largest overlap with
the building.
"""
# Get the total area of the intersection between a GHSL type and the building.
@@ -39,14 +40,14 @@ class GHSLCharacteristicsInformation:
ST_Area(
ST_Intersection(geom, ST_Buffer(ST_GeomFromText('{geometry_wkt}', 4326),0)
), True)
) AS area
)
"""
# Select the type with the largest overlap with the building.
sql_statement = f"""
SELECT type
FROM (
SELECT type, {get_area_function}
SELECT type, {get_area_function} AS area
FROM ghsl_characteristics
WHERE geom && ST_GeomFromText('{geometry_wkt}', 4326)
GROUP BY type
Loading