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

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Wed Feb 5 04:14:27 PST 2020


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


More information about the gdal-dev mailing list