9

I have latitudes and longitudes from a GPS unit which uses WGS84, and would like to project those to some kind of plane.

I'm totally new to this, but after a lot of reading it sounds like UTM is a good projection to use. According to the Wiki page on UTM, I'm in zone 34H (a very nice place to live, by the way).

I found two python modules to help me do this:

(1) Using pyproj, which wraps Proj4:

from pyproj import Proj
p = Proj(proj='utm', ellps='WGS84', zone='34H')
lat, lon = -34.228258, 18.413602
p(lon, lat)

Which results in:

(261762.5589262726, -3790491.0744062006)

(2) Using utm:

import utm
lat, lon = -34.228258, 18.413602
utm.from_latlon(lat, lon)

Which results in:

(261762.55890839838, 6209508.925565818, 34, 'H')

As you can see, the y values differ, but the x values are the same for all practical purposes. It looks like the y values are shifted by about 9999999.999972, but not scaled. So it seems that these modules are using different origins for the xy plane.

  1. Which one is right?
  2. How can I change it using either module?
1
  • the latitude band 'H' should be removed, just use zone=34
    – Mike T
    Apr 15, 2021 at 21:36

2 Answers 2

11

Both coordinates are the same. As you are in the Southern Hemisphere a False Northing (of +10000000m) is usually applied to eliminate the negatives.

The utm package applies the false Northing by itself. For Proj you need to specify it:

>>> p = Proj(proj='utm', ellps='WGS84', zone=34, south=True)
>>> p(lon,lat)
>>> (261762.55892627264, 6209508.925593799)
0
1

https://pyproj4.github.io/pyproj/stable/examples.html#find-utm-crs-by-latitude-and-longitude

from pyproj import Proj
from pyproj.aoi import AreaOfInterest
from pyproj.database import query_utm_crs_info

lat, lon = -34.228258, 18.413602
utm_crs_list = query_utm_crs_info(
    datum_name="WGS 84",
    area_of_interest=AreaOfInterest(
        west_lon_degree=lon,
        south_lat_degree=lat,
        east_lon_degree=lon,
        north_lat_degree=lat,
    ),
)
p = Proj(int(utm_crs_list[0].code))
p(lon, lat)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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