[postgis-users] shp2pgsql - reversing x,y coordinates?

Michael Fuhr mike at fuhr.org
Tue Aug 1 13:01:50 PDT 2006


On Tue, Aug 01, 2006 at 03:20:22PM -0400, Peter Fay wrote:
> I am trying to import a shapefile into postgis using shp2pgsql, and the
> order of coordinates is getting reversed in the output of shp2pgsql.  (x,y)
> becomes (y,x).  Does anyone have an answer?  And how does one get the output
> to be (x,y)?
> 
> >shp2pgsql.exe -D -i -w -s 4326 -I -g line "gshhs_land.shp" public.shoreline
> > shoreline.sql
> 
> The shapefile is from the NOAA:
> 
> http://www.ngdc.noaa.gov/mgg/shorelines/data/gshhs/version1.3/shapefiles/gshhs_land/

I ran shp2pgsql on this file and the coordinates appear to be (x y),
at least for the geometries I examined.  The first geometry in the
output is

MULTILINESTRING((180 68.993782043457,179.996780395508 68.9954681396484
...
179.04167175293 69.3079223632812,179.044998168945 69.3078918457031))

Is that not what you're getting?  Is it possible that you're
misreading the middle numbers in (x1 y1,x2 y2) as (y1,x2)?
A space separates x and y; a comma separates (x y) pairs.

-- 
Michael Fuhr



More information about the postgis-users mailing list