Skip to content

Instantly share code, notes, and snippets.

@koslib
Created February 24, 2017 15:59
Show Gist options
  • Save koslib/ef232cacc093380e1bde0d036fea501e to your computer and use it in GitHub Desktop.
Save koslib/ef232cacc093380e1bde0d036fea501e to your computer and use it in GitHub Desktop.
Check if specific geo point lies inside a MultiPolynomial area (Django & GeoDjango)
from django.contrib.gis.geos import GEOSGeometry
p = GEOSGeometry("Point(-3.735295 21.624602)", srid=4326) # 4326 for standard lng/lat coordinates
# Transform to same coordinate system as maps
p.transform(27700)
RegionBorder.objects.filter(mpoly__contains=p)
[<RegionBorder: Athens>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment