I am drawing address points and checking if they are inside a large shapefile. However, now I also want to check if they fall inside type URBAN. This information comes in terms of a list of features in which one of the columns is TYPE. I pass if the point I want is urban or not (urban=True)
My code for the cointaining point:
def get_random_point_in_polygon(region, urban=None):
while True:
address = ogr.Geometry(ogr.wkbPoint)
address.AddPoint(random.uniform(region.get_region().geometry().GetEnvelope()[0],
region.get_region().geometry().GetEnvelope()[1]),
random.uniform(region.get_region().geometry().GetEnvelope()[2],
region.get_region().geometry().GetEnvelope()[3]))
if region.get_region().geometry().Contains(address) and XXXXXXXXXX:
return address
Region is a large shapefile Now I also have a list of other 52 features that are all inside region. They have a FIELD that contains the information URBAN or RURAL.
I want to fulfill my XXXXXX with a code that says: 'if address is inside any features in the list that FIELD = URBAN'
Any ideas? Something like:
any(x in a for x in b)
but for shapefiles...