I'm trying to do a fairly simple analysis by buffering points (SEPTA subway stations [below]) and counting the number of 'incidents' (also points) that lie within the buffer. That's it.
I've done some looking online, but I can't find anything specific. Maybe it's so easy that nobody needs to ask. I could really use some help.
I was able to fix the code and create a buffer for the points, but I can't seem to be able to count the points that come within the buffer. Also, there was an issue with the 'incidents' point set that I was using, so I switched it with 'Farmers Markets'. Below is what I've got so far. Again, I just need to count the points.
from osgeo import ogr
septaclip = ogr.Open(r'/home/user/Downloads/SEPTAclip.shp')
septalyr = septaclip.GetLayer(0)
citylimits = ogr.Open(r'/home/user/Downloads/City_Limits.shp')
citylyr = citylimits.GetLayer(0)
crimestat = ogr.Open(r'/home/user/Downloads/Farmers_Markets.shp')
crimelyr = crimestat.GetLayer(0)
memory_driver = ogr.GetDriverByName('Memory')
memory_ds = memory_driver.CreateDataSource('Temp')
buff_lyr = memory_ds.CreateLayer('Buffer')
buff_feat = ogr.Feature(buff_lyr.GetLayerDefn())
multipoly = ogr.Geometry(ogr.wkbMultiPolygon)
for septafeat in septalyr:
buff_geo = septafeat.geometry().Buffer(3000)
multipoly.AddGeometry(buff_geo)
#multipoly = (multipoly.UnionCascaded())
for crimefeat in crimelyr:
buffcrime = crimefeat.geometry().Intersection(multipoly)