Hi David,
try creating a list first:
for country in list(countryCollect):
then when you have found the station you may want to delete that station
from the loaded data. Normally you would do that with the remove
command: stationCollect.remove(station). Unfortunatlly that works only with
list data formats...
Cheers,
Esteban
David Fawcett writes:
« HTML content follows »
I am working through a couple of iterations of examples using Shapely do
point in poly intersects. I plan to add prepared geometries and rtree in
future examples, but I am starting with the basics.
I have county polys and station points. I am using fiona to open up the
shapefiles and create collections.
My outer loop goes through the counties and the inner loop goes through
each station, testing whether the station intersects() the county.
It appears as though I need to reset or recreate the station collection
between each outer loop iteration. It seems inefficient to reload the
collection from disk each time, but I don't see a .reset() method or
anything like that.
What is the best way to implement this? In the below example, I only get
a list of station xy's in the first iteration of the outer loop.
Thanks,
David.
stationCollect = fiona.open(stationPath,'r')
countyCollect = fiona.open(countyPath,'r')
for county in countyCollect:
countyGeom = shape(county['geometry'])
for station in stationCollect:
stationGeom = shape(station['geometry'])
print stationGeom.x, stationGeom.y
if stationGeom.intersects(countyGeom):
print station['properties']['SYS_LOC_CO']
print county['properties']['COUNTYNAME']
countyCollect.close()
stationCollect.close()
--
You received this message because you are subscribed to the Google Groups
"Unofficial Python GIS SIG" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
For more options, visit
<URL:https://groups.google.com/groups/opt_out>https://groups.google.com/gro
ups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"Unofficial Python GIS SIG" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.