[Proj] Using cs2cs.

Hermann Peifer peifer at gmx.eu
Mon Apr 30 05:03:51 PDT 2012


On 30/04/2012 11:27, Joshua Brown wrote:
> On 30/04/12 07:57, Hermann Peifer wrote:
>> On 30/04/2012 05:54, Joshua Brown wrote:
>>> Hello,
>>>
>>> I have a text file, with each OSGB32 value on a new line.
>>>
>>> I want to convert from OSGB32 to WGS84 so I can map values to google
>>> earth.
>>>
>>> How can I use cs2cs to convert the text file into WGS84?
>>>
>>
>> I assume that with OSGB32 you actually mean: OSGB36. I have recently
>> been using [1] and [2] for getting from OSGB36 to WGS84. [2] is the more
>> accurate alternative. You can find a link to OSTN02_NTv2.gsb at the PROJ
>> wiki page, see [3].
>>
>> Hermann
>>
>> [1]
>> cs2cs -v -f "%.6f" +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717
>> +x_0=400000 +y_0=-100000 +ellps=airy
>> +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +to
>> +proj=longlat +datum=WGS84
>>
>> [2]
>> cs2cs -v -f "%.6f" +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717
>> +x_0=400000 +y_0=-100000 +ellps=airy +nadgrids=./OSTN02_NTv2.gsb  +to
>> +proj=longlat +datum=WGS84
>>
>> [3] http://trac.osgeo.org/proj/wiki
>
> Thanks for the response,
>
> Yes I do mean OSGB36 ... I think. I have National grid references in the
> format "SH1234512456" that I need to convert.
>

You have to pre-process your grid references in order to get Easting and 
Northing values in metres from the false origin of the grid. The 
2-letter code "SH" basically means that you have to add 200000 metres to 
your Easting value 12345 and 300000 metres to your Northing value of 
12456. Once the pre-processing is done, you can use cs2cs as suggested 
above, e.g.:

$ echo $((200000 + 12345)) $((300000 + 12456)) |
cs2cs -v -f "%.6f" +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 
+x_0=400000 +y_0=-100000 +ellps=airy 
+towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +to 
+proj=longlat +datum=WGS84

# ---- From Coordinate System ----
#Transverse Mercator
#       Cyl, Sph&Ell
# +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000
# +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489
# ---- To Coordinate System ----
#Lat/long (Geodetic alias)
#
# +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0

-4.777201       52.677222 52.494866

For the individual offsets by 2-letter code, you could have a looks at:
http://www.ordnancesurvey.co.uk/oswebsite/support/knowledgebase/calculating-distances-using-national-grid-references.html

Hermann



More information about the Proj mailing list