Reproject CSV Data

View: New views
2 Messages — Rating Filter:   Alert me  

Reproject CSV Data

by ernst_meier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
http://lists.maptools.org/mailman/listinfo/fwtools
http://fwtools.maptools.org/

Re: Reproject CSV Data

by Newman, Michael :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@... [mailto:fwtools-bounces@...] On Behalf Of Ernst Meier
Sent: Monday, July 20, 2009 1:30 PM
To: fwtools@...
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@...
http://lists.maptools.org/mailman/listinfo/fwtools
http://fwtools.maptools.org/

_______________________________________________
FWTools mailing list
FWTools@...
http://lists.maptools.org/mailman/listinfo/fwtools
http://fwtools.maptools.org/