4

I'm using GeoDjango with PostGIS. I have a table with a polygon field called "geofence".

I want to add a 5m buffer zone around the polygon.

obj.geofence.buffer(5)

This results in a huge buffer zone though. Experimentally it looks like the buffer zone is around 500km wide.

It appears that I must somehow do a transformation of my meter unit to the system used by polygon.buffer. How can I do that?

1

1 Answer 1

5

Which SRID are you using?

If you are using WGS84, Try this:

distance = 5 # distance in meter
buffer_width = distance / 40000000.0 * 360.0
buffered = obj.geofence.buffer(buffer_width)

Source: https://stackoverflow.com/questions/31940674/optimal-query-in-geodjango-postgis-for-locations-within-a-distance-in-meters

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.