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

Nathan Gerber ngerber999 at gmail.com
Thu Dec 30 17:50:46 PST 2010


I had to build a rather complex fixing script as the problems are quite
varied. Some could be fixed with a simple st_buffer(geom,0) while others
required more advanced cleaning. Below is an incomplete list of problems I
found while sorting through the data:


   - Figure eights or as I like to call them, Loop-di-dos |><|
   - Self-Intersections at river heads due to the rather simplistic boundary
   simplification algorithms used.
   - Boundaries that back tracked along themselves.
   - Boundaries that contained a line off the boundary that represented a
   peninsula or pier that had zero area.
   - Overlapping borders that had to be cleaned for my data set so that no
   single point could belong in two countries.
   - There were also a few inconsistencies with naming conventions that had
   to be manually corrected based upon some research (thank you wikipedia).
   - Missing state/province and/or county/muncipality borders that left a
   few holes at the sub-country level in a few areas.
   - Some of my missing data and inconsistencies may have been corrected
   since I pulled the data a year or so ago.

I'd offer to send you my cleaned up data set but unfortunately it has been
updated with some proprietary data for Canada and Mexico.
--
Nathan Gerber


On Thu, Dec 30, 2010 at 7:03 PM, David Blackman <david at whizziwig.com> wrote:

> 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
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20101230/04ed347b/attachment.html>


More information about the postgis-users mailing list