[gdal-dev] Command line text input (a WKT) to OGR e.g. to transform a coordinate using ogr2ogr?

Stefan Keller sfkeller at gmail.com
Thu Feb 6 10:12:17 PST 2020


Hi Brad, hi Jukka

Thank you for the tips!

Seems that in fact cs2cs works similar to GDAL and both seem to be
installed e.g. with QGIS

cs2cs +init=epsg:4326 +to +init=epsg:2056

:Stefan

Am Mi., 5. Feb. 2020 um 13:14 Uhr schrieb jratike80
<jukka.rahkonen at maanmittauslaitos.fi>:
>
> Hi,
>
> Gdaltransform should be a rather close hit
> https://gdal.org/programs/gdaltransform.html#gdaltransform
>
> Usage example with your point
>
> gdaltransform -s_srs epsg:4326 -t_srs epsg:2056
> Enter X Y [Z [T]] values separated by space, and press Return.
> 10.1989 45.9461
> 2814015.23490644 1092044.84521026 0
>
> But of course you can do the same with ogrinfo and SQLite SQL dialect. Here
> done on Windows and with a WKT written into the command. Notice that for
> ogrinfo some vector source must exist even the command does not read any
> data from there.
>
> ogrinfo -dialect sqlite -sql "select
> st_x(st_transform(setsrid(st_geomfromtext('POINT(10.1989
> 45.9461)'),4326),2056))||','||st_y(st_transform(setsrid(st_geomfromtext('POINT(10.1989
> 45.9461)'),4326),2056)) as xy" foo.shp|find "xy"
> xy: String (0.0)
>   xy (String) = 2814015.23490644,1092044.84521027
>
> -Jukka Rahkonen-
>
>
>
> Stefan Keller wrote
> > Hi,
> >
> > I'd like to transform a single coordinate e.g. from SRS 4326 to local
> > Swiss EPSG 2056 without creating a file before hand - just like an
> > calculator.
> >
> > Is this possible in a command line shell (like Win cmd/powershell,
> > bash) e.g. in the following (not yet functional) form:
> >
> > echo "POINT(10.1989 45.9461)" | ogr2ogr -f CSV ?stdout ?stdin -s_srs
> > EPSG:4326 -t_srs EPSG:2056 ...?
> > echo "POINT(10.1989 45.9461)" | ogr2ogr -f CSV ?stdout ?stdin -s_srs
> > EPSG:4326 -t_srs EPSG:2056 -sql "select OGR_GEOM_WKT from input" ...?
> >
> > :Stefan
> > _______________________________________________
> > gdal-dev mailing list
>
> > gdal-dev at .osgeo
>
> > https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>
>
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list