I am using Pandas and PyProj to convert eastings and northing to longitutde and latitude and then save the split output into 2 columns like this....
v84 = Proj(proj="latlong",towgs84="0,0,0",ellps="WGS84")
v36 = Proj(proj="latlong", k=0.9996012717, ellps="airy",
towgs84="446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894")
vgrid = Proj(init="world:bng")
def convertLL(row):
easting = row['easting']
northing = row['northing']
vlon36, vlat36 = vgrid(easting, northing, inverse=True)
converted = transform(v36, v84, vlon36, vlat36)
row['longitude'] = converted[0]
row['latitude'] = converted[1]
return row
values = pd.read_csv("values.csv")
values = values.apply(convertLL, axis=1)
This is working but is very slow and times out on larger datasets. In an effort to improve things I am trying to convert this to use a lamba function instead in the hopes that will speed things up. I have this so far...
def convertLL(easting, northing):
vlon36, vlat36 = vgrid(easting, northing, inverse=True)
converted = transform(v36, v84, vlon36, vlat36)
row = row['longitude'] = converted[0]
return row
values ['longitude'] = values.apply(lambda row: convertLL(row['easting'], row['northing']), axis=1)
This converted version is working and is faster than my old one and does not time out on larger datasets, but this only works for the longitude, is there a way to get it to do latitude as well?
Also, is this vectorized? Can I speed things up any more?
EDIT
A sample of data...
name | northing | easting | latitude | longitude
------------------------------------------------
tl1 | 378778 | 366746 | |
tl2 | 384732 | 364758 | |