May 2017
Beginner to intermediate
328 pages
7h 17m
English
PostGIS can try to fix validity errors automatically. A ST_MakeValid function is designed for this. It's convenient to use, but it's not a magic wand; if a geometry is an hourglass-shaped polygon, it will remain so, only converted to a MultiPolygon to ensure formal validity. Sometimes it's better to extract invalid geometries and have a closer look at them using desktop GIS software. When this is not practical, ST_MakeValid can be used as a quick remedy:
UPDATE data_import.ne_110m_land SET geom = ST_MakeValid(geom);
The ST_MakeValid will not touch geometries that are already valid, so an additional WHERE clause is not needed.
Now, look at the following query:
SELECT * FROM data_import.ne_110m_land WHERE ST_IsValid(geom) ...
Read now
Unlock full access