Home > Software engineering >  Converting UTM to Lat/Long without zone information
Converting UTM to Lat/Long without zone information

Time:10-04

I'm trying to convert UTM data (easting/northing) to lat/long, but the data I'm using doesn't have any zonal data.

I know I could just use an online converter but I have thousands of rows so this isn't viable.

The data is already in my notebook as a df, so ideally I want to replace the easting/northing columns with separate lat/long columns.

Location_Easting Location_Northing
530,171.0000 179,738.0000
515,781.0000 174,783.0000
531,614.0000 184,603.0000

I tried this line of code but I get a TypeError saying the 'module' is not callable

myProj = proj (" proj=utm zone=23K, south ellps=WGS84 datum=WGS84 units=m no_defs")

I know it asks for a zone but like I said I don't have this data.

Thanks in advance!

I've now made an educated guess to my UTM zone (30U), but when I run the below code (updated) I'm told the module is still not callable - from my understanding of this link it should be appropriate for my project? https://pyproj4.github.io/pyproj/stable/api/proj.html

myProj = Proj (" proj=utm zone=30U, north ellps=WGS84 datum=WGS84 units=m no_defs")

I've since found code which will convert my metres and zone data to lat/long, but does anyone know how I can apply this to a whole dataframe (bus_stops)? posx should be column 'Location_Easting' and posy should relate to column 'Location Northing'

from shapely.geometry import Point

posx = 530,171
posy = 179,738.0000

# utm 24s is equivalent to epsg:32724
lon, lat = GeoSeries([Point(posx, posy)], crs='EPSG:32630').to_crs('epsg:4326')[0].coords[0] 

print(lon, lat)```

-7.483995602218547 0.0015423233602163576

CodePudding user response:

The error message saying that module is not callable is an evidence that you are trying to directly use the module when you should use a class from it.

Here is an declaration example using the pyproj module:

import pyproj

myProj = pyproj.Proj (" proj=utm  zone=30  north  ellps=WGS84"
                      "  datum=WGS84  units=m  no_defs")
  • Related