Skip to content

Instantly share code, notes, and snippets.

@jgomezdans
Created December 8, 2010 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgomezdans/733207 to your computer and use it in GitHub Desktop.
Save jgomezdans/733207 to your computer and use it in GitHub Desktop.
from osgeo import ogr
# First, define our point. Using WKT, but could use a OGR source or something
my_point = ogr.CreateGeometryFromWkt( \
"POINT( 224021.425476915, 4114664.1465754998)" )
dataset = ogr.Open ( FILENAME )
layer = dataset.GetLayer ( 0 ) # Or whatever it is you require
# You may also want to apply some spatial subsetting to the layer here
# Loop over features
for feat in layer:
geom = feat.GetGeometryRef()
if geom.Contains ( my_point ):
# Do something with it: add to some dataset, report etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment