[gdal-dev] ogr2ogr failing on postgis?

2016-04-10 Thread Paolo Cavallini
Hi all,
I have an ogr2ogr command, from shp to pg, that fails because it
requests write access to spatial_ref_sys. An apparently identical
command on another file runs smoothly. Any hint?
Details and data documented here:
http://hub.qgis.org/issues/14650
Thanks.
-- 
Paolo Cavallini - www.faunalia.eu
QGIS & PostGIS courses: http://www.faunalia.eu/training.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] ogr2ogr failing on postgis?

2016-04-10 Thread Dmitry Baryshnikov

Hi Paolo,

It seems to me that your shape spatial reference not present in 
spatial_ref_sys and GDAL try to import it into spatial_ref_sys.

Your shape file have such SRS:
PROJCS["Monte_Mario_Italy_zone_1",GEOGCS["GCS_Monte 
Mario",DATUM["D_Monte_Mario",SPHEROID["International_1924",6378388,297]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",9],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",150],PARAMETER["false_northing",0],UNIT["Meter",1]]


If I execute such SQL: select * from spatial_ref_sys where srtext like 
'%Monte_Mario%' I received:


4265;"EPSG";4265;"GEOGCS["Monte 
Mario",DATUM["Monte_Mario",SPHEROID["International 
1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],AUTHORITY["EPSG","6265"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745 
(...)"
4806;"EPSG";4806;"GEOGCS["Monte Mario 
(Rome)",DATUM["Monte_Mario_Rome",SPHEROID["International 
1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],AUTHORITY["EPSG","6806"]],PRIMEM["Rome",12.452333,AUTHORITY["EPSG","8906"] 
(...)"
3003;"EPSG";3003;"PROJCS["Monte Mario / Italy zone 1",GEOGCS["Monte 
Mario",DATUM["Monte_Mario",SPHEROID["International 
1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],AUTHORITY["EPSG","6265"]],PRIMEM["Greenwich",0,AUTHORITY[" 
(...)"
3004;"EPSG";3004;"PROJCS["Monte Mario / Italy zone 2",GEOGCS["Monte 
Mario",DATUM["Monte_Mario",SPHEROID["International 
1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],AUTHORITY["EPSG","6265"]],PRIMEM["Greenwich",0,AUTHORITY[" 
(...)"
26591;"EPSG";26591;"PROJCS["Monte Mario (Rome) / Italy zone 1 
(deprecated)",GEOGCS["Monte Mario 
(Rome)",DATUM["Monte_Mario_Rome",SPHEROID["International 
1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],AUTHORITY["EPSG","6806"]], 
(...)"
26592;"EPSG";26592;"PROJCS["Monte Mario (Rome) / Italy zone 2 
(deprecated)",GEOGCS["Monte Mario 
(Rome)",DATUM["Monte_Mario_Rome",SPHEROID["International 
1924",6378388,297,AUTHORITY["EPSG","7022"]],TOWGS84[-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68],AUTHORITY["EPSG","6806"]], 
(...)"


I think you need to reproject shape file to EPSG: 3003 or defined it for 
shape file.


Best regards,
Dmitry

10.04.2016 18:23, Paolo Cavallini пишет:

Hi all,
I have an ogr2ogr command, from shp to pg, that fails because it
requests write access to spatial_ref_sys. An apparently identical
command on another file runs smoothly. Any hint?
Details and data documented here:
http://hub.qgis.org/issues/14650
Thanks.


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] ogr2ogr failing on postgis?

2016-04-10 Thread Even Rouault
Hi Paolo,

> Hi all,
> I have an ogr2ogr command, from shp to pg, that fails because it
> requests write access to spatial_ref_sys. An apparently identical
> command on another file runs smoothly. Any hint?
> Details and data documented here:
> http://hub.qgis.org/issues/14650

Yes, this is expected and a rather common problem with shapefiles. As the 
shapefile .prj doesn't contain any explicit EPSG code, the PostGIS driver tries 
to find a match in spatial_ref_sys based on an exact match on the WKT, but as 
the OGC WKT built from the .prj is different from the one in spatial_ref_sys 
(one of the difference is the absence of the AUTHORITY["EPSG","3003"] node of 
course !), it must fallback to creating an ad-hoc entry, hence the need for 
write access.

Workaround: provide explicit SRS, in that case -a_srs EPSG:3003 (as I can see 
in the .qpj)

A more "fuzzy" indentification of SRS could help for that.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] ogr2ogr failing on postgis?

2016-04-10 Thread Paolo Cavallini
Il 10/04/2016 18:01, Even Rouault ha scritto:

> Yes, this is expected and a rather common problem with shapefiles.

Thanks a lot for the explanation. QGIS therefore creates an incorrect
prj, but I did not noticed it because it loaded it with the correct
EPSG. Ticket upstream opened:
http://hub.qgis.org/issues/14655
All the best, and thanks.
-- 
Paolo Cavallini - www.faunalia.eu
QGIS & PostGIS courses: http://www.faunalia.eu/training.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] ogr2ogr failing on postgis?

2016-04-10 Thread Even Rouault
Le dimanche 10 avril 2016 20:39:25, Paolo Cavallini a écrit :
> Il 10/04/2016 18:01, Even Rouault ha scritto:
> > Yes, this is expected and a rather common problem with shapefiles.
> 
> Thanks a lot for the explanation. QGIS therefore creates an incorrect
> prj, but I did not noticed it because it loaded it with the correct
> EPSG. Ticket upstream opened:
> http://hub.qgis.org/issues/14655

No, QGIS did it fine (actually I suspect it generates .prj file through OGR 
itself). ESRI .prj file are supposed *not* to contain EPSG codes unfortunately. 
This is the ESRI WKT variant. Which makes it hard to deal with them on the 
reading side. The issue is more on the OGR side.

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev