[postgis-users] Trying to import natural earth data into postgis 1.5.2

David Blackman david at whizziwig.com
Thu Dec 30 16:03:15 PST 2010


Hi all--

I'm trying to import the 10m-admin-1 data from
http://www.naturalearthdata.com/ to postgis 1.5.2. It's generating a
lot of invalid geometry that I don't know how to fix.

My import command looks like this:

shp2pgsql -W LATIN1 -I 10m-admin-1-states-provinces-shp >
10m-admin-1-states-provinces-shp.sql
(note, in postgis2, this entirely fails on invalid input characters,
none of the character sets I tried worked)

and of the import, 148 rows have invalid geometry, with errors like:
blackmad=# select fips_1 FROM
public."10m-admin-1-states-provinces-shp" WHERE ST_IsValid(the_geom) =
false;
NOTICE: Holes are nested at or near point 101.662 3.04074
NOTICE: Self-intersection at or near point 120.185 22.9625
NOTICE: IllegalArgumentException: Invalid number of points in
LinearRing found 2 - must be 0 or >= 4
NOTICE: Ring Self-intersection at or near point -47.3025 -16.0401
NOTICE: Too few points in geometry component at or near point -65.458 -22.1012

This cleangeometry.sql script @
http://www.sogis1.so.ch/sogis/dl/postgis/cleanGeometry.sql fixes most,
but the LinearRing errors cause the script to choke.

Can someone advise me on how to fix these errors, or where the problem
lies (in the data or the import tool)?

thanks
--dave



More information about the postgis-users mailing list