Skip to content

Instantly share code, notes, and snippets.

@snodnipper
Last active December 24, 2015 09:51
Show Gist options
  • Save snodnipper/5e25b821ca06a13981b0 to your computer and use it in GitHub Desktop.
Save snodnipper/5e25b821ca06a13981b0 to your computer and use it in GitHub Desktop.
Using stock tools, I couldn't see an easy way to transform multiple columns simultaneously. Still, one could write out three separate files. See: https://github.com/snodnipper/bng-transformations/tree/master/examples/ogr2ogr
<OGRVRTDataSource>
<OGRVRTLayer name="process">
<SrcDataSource>process.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs +nadgrids=/Users/osnowden/code/bng-transformations/OSTN02_NTv2.gsb</LayerSRS>
<GeometryField encoding="PointFromColumns" x="MBR_XMIN" y="MBR_YMIN"/>
</OGRVRTLayer>
</OGRVRTDataSource>
<OGRVRTDataSource>
<OGRVRTLayer name="input">
<SrcDataSource>input.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs +nadgrids=/Users/osnowden/code/bng-transformations/OSTN02_NTv2.gsb</LayerSRS>
<GeometryField encoding="PointFromColumns" x="MBR_XMAX" y="MBR_YMAX"/>
</OGRVRTLayer>
</OGRVRTDataSource>
<OGRVRTDataSource>
<OGRVRTLayer name="process2">
<SrcDataSource>process2.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs +nadgrids=/Users/osnowden/code/bng-transformations/OSTN02_NTv2.gsb</LayerSRS>
<GeometryField encoding="PointFromColumns" x="GEOMETRY_X" y="GEOMETRY_Y"/>
</OGRVRTLayer>
</OGRVRTDataSource>
ogr2ogr -f 'CSV' -lco GEOMETRY=AS_XY -t_srs EPSG:4326 -nln output process.csv 3.vrt
ogr2ogr -f 'CSV' -lco GEOMETRY=AS_XY -t_srs EPSG:4326 -nln process process2.csv 2.vrt
ogr2ogr -f 'CSV' -lco GEOMETRY=AS_XY -t_srs EPSG:4326 -nln output output.csv input.vrt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment