I've got a .csv file that contains a long list of latitude and longitude points. Is there an efficient way to batch convert the list into a projected UTM coordinate system?
Perhaps the simplest way is using something like QGIS and its delimited text plugin to import and then export the data. If you're looking for something commandline and scalable, then the VRT approach Sasa mentioned is a good one.
You can also do it with file inputs and outputs using
gdaltransform -s_srs epsg:4326 -t_srs epsg:25832 < space-delimited-coordinates.txt
And if you need more programmatic access to the results, check out geographika's answer using pyroj for a related question.
add the csv and use the lat longs to create an event table. (right click layer> "Display XY Data")
This creates an event layer with the table and a point layer (not a real point layer, it needs to be exported later)
set the document projection (data frame properties) to the desired output of the file. (right click layers "in the TOC">properties> coordinate system tab).
right click the layer in TOC > Export Data
Use the option to "use the same coordinate system as: the data frame"
ogr2ogr should be able to handle this (you can download FWTools for a quick install).
This thread illustrates how to reproject CSV data. To summarize, you'll need to create a VRT file that contains references to the CSV columns:
<OGRVRTDataSource> <OGRVRTLayer name="test"> <SrcDataSource>test.csv</SrcDataSource> <GeometryType>wkbPoint</GeometryType> <GeometryField encoding="PointFromColumns" x="RW" y="HW"/> </OGRVRTLayer> </OGRVRTDataSource>
And then run ogr2ogr for reprojection:
ogr2ogr -s_srs "epsg:31466" -t_srs "epsg:25832" -f "CSV" -lco GEOMETRY=AS_XY -sql "SELECT PNR FROM test" temp_dir test.vrt
You'll need to replace epsg:31466 with the appropriate EPSG code for your UTM coordinate system.
There are working spreadsheets and other source code (Fortran, C++, etc.) at http://www.gpsy.com/gpsinfo/geotoutm/ Great resource for 1996 (and still works)!
We have a commercial (but affordable) standalone desktop application that will allow you to batch convert your coordinates. More information can be found at: http://geomaticsolutions.com/products/geo-suite/geo-calc
You can also use our free online service to perform single point transformations. http://georepository.com/home.html
As I understand it, you do not want to simply reproject a file, you want to convert the coordinates themselves and have a new file with the new coordinates. If you Google "convert lat/lon to utm" you should find excel spreadsheets that will do this conversion (e.g. at the University of Wisconsin Green Bay or in whuber's answer above). Or, you can purchase software like AllTrans or Franson Coordtrans, which batch convert to and from many different coordinate systems.
Or, less simple but more educational, is to learn syntax for gdal or FWTools.
For a scripting solution, you could use pyproj:
import sys import csv import pyproj # example invocation # ./reproj.py ./file.csv 32619 4326 if (len(sys.argv) != 4): print '%s <csvfile> <epsg_code_in> <epsg_code_out>' % sys.argv sys.exit(1) else: p1 = pyproj.Proj(init='epsg:%s' % sys.argv) p2 = pyproj.Proj(init='epsg:%s' % sys.argv) f = open(sys.argv, 'r') table = csv.reader(f) for row in table: print '%s %s' % (row, row) newxy = pyproj.transform(p1, p2, row, row) print '%s %s' % (row, newxy, newxy) f.close()
The following new site converts files online. (It uses pyproj)
It also generates KML and the input file can often be left 'as is' and not reformatted to suite the conversion program.
Sorry i cant post a numeric domain so have to wrap it in a code block! http://188.8.131.52/XYZ_tools
Please cut and paste the link to follow it.
I would not go for ARC solution; for these common conversions there are many online tools such as http://www.hamstermap.com - just copy and paste a list of coordinates and you will get them instantly converted.