[FWTools] Reproject CSV Data

Newman, Michael (Windsor,CT-US) MNewman at trcsolutions.com
Fri Jul 24 20:37:14 EST 2009


Ernst,

According to:
http://gdal.org/ogr/drv_csv.html
There is an option:
-lco GEOMETRY=AS_XY
which can get you the results you need.

Based on your example (test.csv and test.vrt), try running this in the same directory as those 2 examples files:

ogr2ogr -s_srs "epsg:31466" -t_srs "epsg:25832" -f "CSV" -lco GEOMETRY=AS_XY -sql "SELECT PNR FROM test" temp_dir test.vrt

Which will create a subdirectory called "temp_dir" with the file "test.csv" in it:
X,Y,PNR
361782.58712580614,5643998.0837264238,1001

Note the SQL statement is required to keep PNR, but get rid of the original RW and HW. If you need to rename those fields, do this additional command:

ogr2ogr -f CSV -sql "SELECT X as RW, Y as HW, PNR from test" output_dir temp_dir

which creates "output_dir\test.csv":
RW,HW,PNR
361782.58712580614,5643998.0837264238,1001

-Mike

-----Original Message-----
From: fwtools-bounces at lists.maptools.org [mailto:fwtools-bounces at lists.maptools.org] On Behalf Of Ernst Meier
Sent: Monday, July 20, 2009 1:30 PM
To: fwtools at lists.maptools.org
Subject: [FWTools] Reproject CSV Data

Here ist my Data: test.csv

RW,HW,PNR
2572617.12,5644342.59,"1001"

My test.vrt:

<OGRVRTDataSource>
    <OGRVRTLayer name="test">
        <SrcDataSource>test.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <GeometryField encoding="PointFromColumns" x="RW" y="HW"/>
    </OGRVRTLayer>
</OGRVRTDataSource>


and here ist my commandline:

ogr2ogr -s_srs "epsg:31466" -t_srs "epsg:25832" -f "CSV" test_etrs.csv test.vrt

and the result:

RW,HW,PNR
2584617.12,5653342.59,1001

I tried cs2cs but i need an extra field for (PNR) identfication.

Ernst
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
_______________________________________________
FWTools mailing list
FWTools at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/fwtools
http://fwtools.maptools.org/



More information about the FWTools mailing list