Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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? Thanks.

share|improve this question
add comment

10 Answers 10

up vote 7 down vote accepted

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:

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.

share|improve this answer
    
Can you be more specific about how I should export the data in QGIS? I tried to right click on the imported layer with the points, click Save As..., and specified UTM 16N as my projected coordinate system. But the resulting file was not changed! –  hpy Apr 5 '11 at 23:03
    
I can.after you load the CSV just point on the layer ruler then do save as>selected crs> select the system to transform to>and save. if you then want to go back to CSV dfsfsd –  yair suari Jan 9 '13 at 9:20
    
some editing problems. if want to go back to csv use the attributes calculator and calculate the $x and $y values on the geometry functionsd to get the location on the nes crs the save again as csv –  yair suari Jan 9 '13 at 9:27
add comment

With arcmap,
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)

display xy

set the document projection (data frame properties) to the desired output of the file. (right click layers "in the TOC">properties> coordinate system tab).

Doc prop

desired projection

right click the layer in TOC > Export Data

export

Use the option to "use the same coordinate system as: the data frame"

export

share|improve this answer
add comment

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.

share|improve this answer
add comment

Corpscon, a free tool from the US Army Corps of Engineers will allow you to batch convert lat/long to/from UTM. Note that it is limited to the United States, and may work in Canada.

share|improve this answer
add comment

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)!

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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[0]
    sys.exit(1)
else:
    p1 = pyproj.Proj(init='epsg:%s' % sys.argv[2])
    p2 = pyproj.Proj(init='epsg:%s' % sys.argv[3])

    f = open(sys.argv[1], 'r')
    table = csv.reader(f)
    for row in table:
        print '%s %s' % (row[1], row[2])
        newxy = pyproj.transform(p1, p2, row[1], row[2])
        print '%s %s' % (row[0], newxy[0], newxy[1])
    f.close()
share|improve this answer
    
Thank you, fellow programmer! NB: this will work if your CSV file has 3+ columns, with your xy data being the second & third columns. I just had to adjust the indexes a bit since my input x/y are in the first two columns. So clear, extensible, and reusable! –  Ahmed Fasih Nov 22 '13 at 3:28
add comment

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://54.251.49.75/XYZ_tools

Please cut and paste the link to follow it.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.