Reputation: 5310
I got a model with field using the gis polygon field.
boundary = models.PolygonField()
As the requirement I need to allow the user to provide offset/tolerance value. How do I expand or shrink this polygon without doing the math myself?
Thanks!
Upvotes: 2
Views: 927
Reputation: 53734
I do believe Geometry.buffer is what you are looking for.
from django.contrib.gis.geos import Polygon
poly = Polygon.from_bbox((0, 0, 5, 5))
poly.extent # (0.0, 0.0, 5.0, 5.0)
p2 = poly.buffer(1)
p2.extent #(-1.0, -1.0, 6.0, 6.0)
if you want to shrink it, use a negative value in the call to buffer
Upvotes: 5