Opened 3 years ago

Closed 3 years ago

#33181 closed Bug (needsinfo)

GeoDjango CoordTransform slightly offset from pyproj transform

Reported by: Henry Bradlow Owned by: nobody
Component: GIS Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I use the GeoDjango CoordTransform function to transform points they end up slightly offset from reality:

TRANSFORM_TO_WGS84 = CoordTransform(SpatialReference('EPSG:32040'), SpatialReference('EPSG:4326'))
points.transform(TRANSFORM_TO_WGS84)

You can see the polygon that is incorrectly intersecting the driveway.

When I use pyproj to do the same transformation, it works as expected:

def project_array(coordinates):
    p1 = pyproj.Proj(init='epsg:32040')
    p2 = pyproj.Proj(init='epsg:4326')
    fx, fy = pyproj.transform(p1, p2, coordinates[:,0], coordinates[:,1])
    return np.dstack([fy, fx])[0]
points = project_array(np.array(points.coords[0]))

You can see the polygon that is correctly bounding the driveway.

Why doesn't the GeoDjango transform behave the same as the pyproj transform?

Attachments (2)

Screen Shot 2021-10-08 at 3.16.53 PM.jpg (228.5 KB ) - added by Henry Bradlow 3 years ago.
Screen Shot 2021-10-08 at 3.31.07 PM.jpg (122.2 KB ) - added by Henry Bradlow 3 years ago.

Download all attachments as: .zip

Change History (3)

by Henry Bradlow, 3 years ago

by Henry Bradlow, 3 years ago

comment:1 by Tim Graham, 3 years ago

Resolution: needsinfo
Status: newclosed

Django mostly just delegates to GDAL, so it could be a bug there, I guess, but this ticket tracker is for reporting confirmed bugs, not for getting help to debug your issues. For that, you could try the geodjango topic on the Django forum. Please reopen this ticket with details if you confirm Django is at fault. Thanks!

Note: See TracTickets for help on using tickets.
Back to Top