Problems with Natural Earth and postGIS

Home Forums Advice & Tutorials Software & Services Problems with Natural Earth and postGIS

This topic contains 3 replies, has 1 voice, and was last updated by  Nathaniel 6 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3466

    trinsic
    Participant

    Hello everyone!

    I’ve been attempting to load some of the Natural Earth vector maps into postGIS, but I have been having some issues.

    To prepare the shapefiles for loading, I have been using the converter tool:

    shp2pgsql -d -W Windows-1252 -G ne_10m_admin_0_map_units.shp mapunits > mapunits.sql

    However, when I run the sql file I consistently get errors:

    ERROR: Coordinate values are out of range [-180 -90, 180 90] for GEOGRAPHY type

    Further investigation show that the failing rows are those associated with Russia and Antartica, leading me to believe it has something to do with polygons crossing the 180 date line.

    I’ve tried with the 10m-admin-0-countries, the 10m-admin-0-mapunits, and the 10m-land shapefiles, all producing the same error.

    Does anyone have any ideas? Is there something wrong with the shapefiles? Am I importing them incorrectly?

    Thanks

    #4236

    Nathaniel
    Keymaster

    See:

    https://github.com/straup/naturalearth-tools

    Specifically:

    +no_defs +over

    Are you using the latest data on the site? That error should have been fixed in the data.

    #4237

    trinsic
    Participant

    Thanks for the suggestion. I am using the latest data on the site.

    Further research has indicated there may be a floating point precision issue with the chain of tools I was using. I ran shp2pgsql again without the -G flag (to create a geometry column instead of a geography column). Looking at the geometry data showed the points clipped to exactly 180. At that point, I was able to successfully cast the geometry column into a geography column without hitting the out-of-bounds error. Still not sure exactly why the shp2pgsql tool could not write to a geography column directly, but it can be worked around.

    #4238

    Nathaniel
    Keymaster

    Thanks for the update. I’ll have to give that a try!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.