Reputation: 12394
Something I do not understand is happening:
from rasterstats import zonal_stats
v = "/Desktop/data/s/g/pg.shp"
r = "/Desktop/data/raw/tem/g01.asc"
stats = zonal_stats(v, r)
Work perfectly. However, I want to iterate through the folder tem
it does not.
pathToRasterFolder = "/Desktop/data/raw/tem/"
for files in os.listdir(pathToRasterFolder):
if files.endswith(".asc"):
zonalStats = ("/Desktop/data/s/g/pg.shp", pathToRasterFolder + files)
print zonalStats
That does not work. My result is:
> ("/Desktop/data/s/g/pg.shp", "/Desktop/data/raw/tem/g01.asc")
Why doesnt it accept the path to the directory with the files?
Upvotes: 0
Views: 41
Reputation: 49803
In the first example, zonal_stats
is a function; in the second, you assign it a tuple.
Upvotes: 2