Search code examples
gispostgisarcgis

pgsql2shp gives different prj values for a identical copy of a postgis table


I have created two postgis tables, copied the content of one table to the other and then attempt to create a shp files of both tables. The generated .prj should be the same as both tables have the same type of geoemtry entry, but I get different values. Has anybody any idea what is going on ? ##My tables

countries

  Column  |            Type             |                        Modifiers                        
----------+-----------------------------+---------------------------------------------------------
gid       | integer                     | not null default nextval('countries_gid_seq'::regclass)
name      | character varying(80)       | 
geom      | geometry(MultiPolygon,4326) | 

Results

  Column  |            Type             |                      Modifiers                       
----------+-----------------------------+---------------------------------------------------------
id        | integer                     | not null default nextval('results_id_seq'::regclass)
label     | text                        | not null
geom2     | geometry(MultiPolygon,4326) | 

##The code Copying result from countries to results insert into results(label,geom2) select name as label, geom as geom2 from countries where name is not null;

##Dumping the data as shape files

pgsql2shp pots results -f results.shp -ggeom2
pgsql2shp pots countries -f countries.shp -gthe_geom

##The issue Both tables have geomtries in the same format ie 4326 I would expect the generated prj files to be the same, but they are different ##The results I get for countries

GEOGCS["WGS84",DATUM["WGS_1984",SPHEROID["WGS4",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]

For results I get

PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS       84",DATUM["WGS_1984",SPHEROID["WGS   84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs"],AUTHORITY["EPSG","3857"],AXIS["X",EAST],AXIS["Y",NORTH]]

I can read both shp files in qgis and it displays the expected results, try reading them with arcgis and there are major issues. To the effect that the two shp files generated from the same data have different projections

What is going on?


Solution

  • Cracked it Its, the arguments where in the wrong order

    Used this way and the results in the correct answer

    pgsql2shp -f results.shp -ggeom2 pots results