[gdal-dev] axis order in gdal_translate

Javier Jimenez Shaw j1 at jimenezshaw.com
Wed Feb 7 09:02:39 PST 2024


Hi

I am calling the python method osgeo.gdal.VectorTranslate to convert a
GeoJSON (with CRS) to shapefile.
To keep consistency among EPSG versions, I have the pipeline of the
conversion, using what in pyproj was "always_xy=True"

            gdal.VectorTranslate(
                dst_file,
                src_file,
                coorindateOperation=coordinateOperation,
                dstSRS="EPSG:4326",
            )

with something like this:
coordinateOperation="+proj=pipeline +step +inv +proj=tmerc +lat_0=44
+lon_0=144.25 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +step +proj=unitconvert
+xy_in=rad +xy_out=deg"

the srcSRS is taken automatically from the GeoJSON.

The first thing I noticed is that EPSG:4326 is left handed, and I have to
swap the axes. Ok, it is easy to add " +step +proj=axisswap +order=2,1"

In the case of EPSG:2455 (left handed CRS in Japan) I should do the swap
also for the input values, that is a bit uglier. (I have to do some parsing
of the pipeline that was generated time ago, and know that EPSG:2455 is
left handed).

Is there a way to tell gdal.VectorTranslate that transformation is
"always_xy", and I do not have to do the swaps manually? Or maybe there is
a better way to do it?

What about the command line gdal_translate?

Thank you.
Javier

.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240207/5e4686b3/attachment.htm>


More information about the gdal-dev mailing list