I need to build a command line batch converter to read in data from a file that includes coordinates in state plane x,y in feet, the coordinate system used and the zone.

For example:

cs: nad83
zone: 402
x: 6929072.797
y: 2040185.208

If I go to an online converter like this one http://www.earthpoint.us/StatePlane.aspx I notice it makes me enter the zone as 4 digits 0402, but other than that it returns the decimal longitude and latitude (among many others) as I would expect.

I've installed the proj4 utility (on my Mac using brew install proj) which seems to have a convenience script cs2cs.

I've reviewed the documentation and searched online for examples but it is still not clear to me what the correct command line syntax is for replicating the same input/output as the online command line example above. From: nad803 zone 402 x & y To: lat lon decimal.

I see many examples that involve converting from utm, using a datum of nad83 but the zones are always from a different system of zone identifiers. I see zone examples of 10, but none like the 3 or 4 digit zone values I am seeing.

Does proj4 / cs2cs accept as an input the 4 digit state plane nad83 zone identifier?

My initial guess is that it does not and instead I must determine the series of options that constitute the parameters for that zone instead of the tool knowing how to look up what that should be.

So, I see here https://github.com/OSGeo/proj.4/blob/master/nad/nad83 that there is a list of what looks like input parameters for each nad83 zone. Terrific, I thought. Trying to make use of the values in this don't produce anything useful in the way I can think to use them.

For instance, using the same values above, I navigate to the entry for zone 402 here https://github.com/OSGeo/proj.4/blob/master/nad/nad83#L61 it provides

# 402: california ii: nad83
<402> proj=lcc  datum=NAD83
lon_0=-122 lat_1=39d50 lat_2=38d20 lat_0=37d40
x_0=2000000 y_0=500000
no_defs <>

So, thinking I've found what I need I try the following:

Not knowing how to tell cs2cs to use feet and to keep my test simple, I convert my values from above to meters so they become 2111981.3885256 621848.4513984

cs2cs +proj=lcc  +a=6378137 +es=.0066943800229 +lon_0=-122 +lat_1=39d50 +lat_2=38d20 +lat_0=37d40 +x_0=2000000 +y_0=500000 +no_defs +to +proj=latlong 2111981.3885256 621848.4513984

and get the following results

Rel. 4.9.3, 15 August 2016
Sys errno: 2: <system mess. texts unavail.>
Rel. 4.9.3, 15 August 2016
Sys errno: 2: <system mess. texts unavail.>

What am I doing wrong here for my manual test of a command line equivalent to the online tool's conversion using the example above of known input values and desired output of decimal latlon?

Is there a simpler straight forward way to provide the nad83 state plane zone value (i.e. zone 402) to cs2cs and have it know the correct options to use?


Ok. Minutes after I posted this I realized that I need to pipe in the input coordinates instead of providing them as arguments and that the input units of feet were already included so I didn't need to convert to meters.


echo 6929072.797 2040185.208 | cs2cs +proj=lcc +lat_1=38.33333333333334 +lat_2=39.83333333333334 +lat_0=37.66666666666666 +lon_0=-122 +x_0=2000000 +y_0=500000.0000000002 +datum=NAD83 +units=us-ft +no_defs +to +proj=latlong


120d42'41.461"W 38d45'25.942"N 0.000

Which appear to be the correct values although they are reversed and not in decimal latlon.

I am still looking for how to get the values in the expected order and how to get them in the correct decimal format and not deg min sec...

Also, a significant question still remains for me... is there a simpler, more straight forward to provide the nad83 zone value to cs2cs and have it know to use the options defined here https://github.com/OSGeo/proj.4/blob/master/nad/nad83 instead of needing to build that lookup logic in my batch script? I'd prefer not to reinvent the wheel.


I realized that I merged two sources of my research into one and the input values I used above were actually from a different source and not the https://github.com/OSGeo/proj.4/blob/master/nad/nad83 zone. So that the life of this post for future readers is accurate, the entry found in that file for zone 402 at the cs2cs command line I've found so far is

echo 6929072.797 2040185.208 | cs2cs +proj=lcc  +a=6378137 +es=.0066943800229 +lon_0=-122 +lat_1=39d50 +lat_2=38d20 +lat_0=37d40 +x_0=2000000 +y_0=500000 +units=us-ft +no_defs +to +proj=latlong

But the questions in my previous update still remain.


To restate the pending question here from the above dialog so it is more clear:

  1. Is there an abbreviated set of option(s) when using cs: nad83 zone:NNNN that can be used for cs2cs that is the equivalent to same options defined in https://github.com/OSGeo/proj.4/blob/master/nad/nad83 for the appropriate zone NNNN instead of needing to have a separate home grown script do the lookup and extract the options from that file.

  2. What option can be used to produce the lat lon output values in decimal format and in the preferred "lat" "lon" order?


Based on the accepted answer below, the missing piece I was looking for is to use +init=nad83:NNNN and it will do the lookup for the correct options using the 3 or 4 digit zone.

Also, the output formatting and order are controlled with the -f and -s options so my final single entry test command line is

echo 6929072.797 2040185.208 | cs2cs +init=nad83:402 +units=us-ft +to -s -f '%.9f%' +proj=latlong

1 Answer 1


It works for me this way:

Put the coordinates in a file named spcs-in.txt:

6929072.797 2040185.208

Put the commandline in a batchfile spcs2nad83.bat:

echo nad83:402 >out.txt
cs2cs +init=nad83:402 +units=us-ft +to +init=epsg:4269 -f "%%.9f" spcs-in.txt >>out.txt
echo epsg:2226>>out.txt
cs2cs +init=epsg:2226 +to +init=epsg:4269 -f "%%.9f" spcs-in.txt >>out.txt

Run it in a OSGEO4W Shell or SDKshell from gisinternals to get identical results:

-120.711517001  38.757206000 0.000000000
-120.711517002  38.757205999 0.000000000

lon-lat is the preferred order in Proj.4, so no solution for that but it can be overridden with -s.

  • Ah - thank you so much! - that +init=nad83:402 part was exactly what I was looking for! Now I can make it dynamic based on the zone and not have to know ahead of time manually what the zone is. Also, I just found in the man page that the -s option can be used to reverse the order of the output to get lat,lon. It has all come together now nicely. Thanks!
    – Streamline
    Nov 21, 2016 at 19:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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