kartoza / fbf-project

Project data and resources for WB Forecast Based Financing work
22 stars 14 forks source link

Invalid geometries in uploaded or osm tables #83

Closed NyakudyaA closed 4 years ago

NyakudyaA commented 4 years ago

Problem

Whilst updating the flood summary tables I encounter the following error

ERROR: lwgeom_difference: GEOS Error: TopologyException: Input geom 0 is invalid: Ring Self-intersection at or near point 107.32477300000005 -6.2842763999999534 at 107.32477300000005 -6.2842763999999534 gis=#

Solution

I have tried to use ST_MakeValid on the flooded_area geometry and still, it didn't work. Maybe we need to do the same for osm_tables. Write a trigger function to update the geometries

NyakudyaA commented 4 years ago

Added validity checks for the tables in the DB and cleaned up existing tables.

update village SET geom=ST_Multi(ST_CollectionExtract(ST_MakeValid(geom), 3)) WHERE NOT ST_IsValid(geom);