[gdal-dev] GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

Simon Eves
I feel like I'm asking a really dumb and naive question again, but here goes...

Our geo importer loads polygons in what I assume is a very standard way. The importer code has not changed in some time, and works fine built against GDAL 2.3.2 and Proj 5.1, and also against GDAL 2.4.1 and Proj 5.2.

When I build our system against GDAL 3.0.0 and Proj 6.1.0, everything seems to work fine, and GeoJSON and KML files import correctly, but Shapefiles result in all the geo being transposed in X/Y!

Simplified code...

sr = new OGRSpatialReference();
sr->importFromEPSG(4326);
ds = GDALOpenEx(file, GDAL_OF_VECTOR, nullptr, nullptr, nullptr);
layer = ds.GetLayer(0)
layer.ResetReading();
f = layer.GetNextFeature();
OGRGeometry* g = f->GetGeometryRef();
if (g->getSpatialReference()) {
  g->transformTo(sr);
}
// omitting code that determines that it's a MULTIPOLYGON
mp = dynamic_cast<OGRMultiPolygon*>(g);
mp->getNumGeometries();
mpg = mp->getGeometryRef(0);
er = mpg->getExteriorRing();
OGRPoint p;
er->getPoint(0, &p);
x = p.getX();
y = p.getY();

and 'x' and 'y' are transposed!

An ogrinfo dump on the command-line displays the correct values.

What did I miss?!

--

Simon Eves
Senior Graphics Engineer, Rendering Group
OmniSci, 1 Front St. #2650, San Francisco, CA 94111, USA


Email: [hidden email] | Cell: 415.902.1996



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

Even Rouault-2
On vendredi 24 mai 2019 13:35:40 CEST Simon Eves wrote:

> I feel like I'm asking a really dumb and naive question again, but here
> goes...
>
> Our geo importer loads polygons in what I assume is a very standard way.
> The importer code has not changed in some time, and works fine built
> against GDAL 2.3.2 and Proj 5.1, and also against GDAL 2.4.1 and Proj 5.2.
>
> When I build our system against GDAL 3.0.0 and Proj 6.1.0, everything seems
> to work fine, and GeoJSON and KML files import correctly, but Shapefiles
> result in all the geo being transposed in X/Y!
>
> Simplified code...
>
> sr = new OGRSpatialReference();
> sr->importFromEPSG(4326);

EPSG:4326 has lat,long order enforced by default in GDAL 3.0
So either cope with it with the x,y you get.
Or add sr->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);



--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

Sean Gillies-3
Even,

To be clear, would replacing

    sr->importFromEPSG(4326);

with

    sr->SetFromUserInput("urn:ogc:def:crs:OGC:1.3:CRS84");

also restore the old behavior? CRS84 is the formally correct identifier for what we've been calling EPSG:4326, right?


On Fri, May 24, 2019 at 2:50 PM Even Rouault <[hidden email]> wrote:
On vendredi 24 mai 2019 13:35:40 CEST Simon Eves wrote:
> I feel like I'm asking a really dumb and naive question again, but here
> goes...
>
> Our geo importer loads polygons in what I assume is a very standard way.
> The importer code has not changed in some time, and works fine built
> against GDAL 2.3.2 and Proj 5.1, and also against GDAL 2.4.1 and Proj 5.2.
>
> When I build our system against GDAL 3.0.0 and Proj 6.1.0, everything seems
> to work fine, and GeoJSON and KML files import correctly, but Shapefiles
> result in all the geo being transposed in X/Y!
>
> Simplified code...
>
> sr = new OGRSpatialReference();
> sr->importFromEPSG(4326);

EPSG:4326 has lat,long order enforced by default in GDAL 3.0
So either cope with it with the x,y you get.
Or add sr->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);



--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev


--
Sean Gillies

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

Even Rouault-2
On vendredi 24 mai 2019 15:00:40 CEST Sean Gillies wrote:

> Even,
>
> To be clear, would replacing
>
>     sr->importFromEPSG(4326);
>
> with
>
>     sr->SetFromUserInput("urn:ogc:def:crs:OGC:1.3:CRS84");
>
> also restore the old behavior? CRS84 is the formally correct identifier for
> what we've been calling EPSG:4326, right?

Could indeed work for that particular case, but for all other EPSG geographic
CRS, or some EPSG projected CRS with northing,easting axis order, you need
either to comply with the EPSG axis order, or revert to the "GIS friendly
order" with SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER)

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: GDAL 3.0.0 / Proj 6.1.0 Shapefile import coordinates X/Y transposed?

Simon Eves
In reply to this post by Even Rouault-2
That would explain it.

I just found RFC 73 and some other stuff in the docs, but perhaps you could put it in the main 3.0 Release Notes? :)

Thank you.

Simon

On Fri, May 24, 2019 at 1:50 PM Even Rouault <[hidden email]> wrote:
On vendredi 24 mai 2019 13:35:40 CEST Simon Eves wrote:
> I feel like I'm asking a really dumb and naive question again, but here
> goes...
>
> Our geo importer loads polygons in what I assume is a very standard way.
> The importer code has not changed in some time, and works fine built
> against GDAL 2.3.2 and Proj 5.1, and also against GDAL 2.4.1 and Proj 5.2.
>
> When I build our system against GDAL 3.0.0 and Proj 6.1.0, everything seems
> to work fine, and GeoJSON and KML files import correctly, but Shapefiles
> result in all the geo being transposed in X/Y!
>
> Simplified code...
>
> sr = new OGRSpatialReference();
> sr->importFromEPSG(4326);

EPSG:4326 has lat,long order enforced by default in GDAL 3.0
So either cope with it with the x,y you get.
Or add sr->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);



--
Spatialys - Geospatial professional services
http://www.spatialys.com


--

Simon Eves
Senior Graphics Engineer, Rendering Group
OmniSci, 1 Front St. #2650, San Francisco, CA 94111, USA


Email: [hidden email] | Cell: 415.902.1996



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev