[OSM-dev] invalid geometry in planet_polygon

Michael Kussmaul kussmaul.list at nix.ch
Wed Aug 25 07:00:32 BST 2010


Hi

This is how we do it:

1.) I import with osm2pgsql like usual, this will create some invalid geometries

2.) I clean the invalid geometries after the import like this:
- Download the cleanGeometry.sql script:
http://www.mail-archive.com/postgis-users@postgis.refractions.net/msg03519/cleanGeometry.sql
- add it to the db:
 sudo -u postgres ./psql -d <dbname> -f cleanGeometries.sql
- then run this update query, where I just replace the invalid geometry with a cleaned geometry:
SQL: update planet_osm_polygon set way=cleanGeometry(way) where not ST_IsValid(way);
(I just do it for polygons, you can do it for ways as well if needed)

This takes a couple of minutes on the europe-db - but not too long.

kind regards
Michael


More information about the dev mailing list