Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting UTM to Lat/Long without zone information

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading