Fehler ist folgender: -Zeile19: rasters: non types not iterable)
Außerdem scheint er die ASCII Files nich einlesen zu können und das Programm muss abgeändert werden auf eine Shapefile als clip für alle ASCII´s.
Weiß jemand Hilfe oder nen besseren weg. Vielen Dank hab schon 1000 versch. Möglichkeiten probiert und dreh langsam durch:D
Code: Alles auswählen
import arcpy, os, sys
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
def main():
# input workspace
raster_ws = r'F:\2014_05\Python Clipping\in'
shp_ws = r'F:\2014_05\Python Clipping\Schablone'
# output workspace
out_ws = r'F:\2014_05\Python Clipping\out'
# get lists
arcpy.env.workspace = raster_ws
rasters = [os.path.join(raster_ws, r) for r in arcpy.ListRasters()]
arcpy.env.workspace = shp_ws
shapes = [os.path.join(shp_ws, s) for s in arcpy.ListFeatureClasses()]
# get dictionary {raster1 : shapefile1.shp, ...}
clip_dict = dict(zip(rasters, shapes))
# clip all rasters
outputList = [] # container
for raster, shapefile in clip_dict.iteritems():
out_raster = os.path.join(out_ws, os.path.basename(raster))
arcpy.Clip_management(raster, "", out_raster, shapefile, "", "ClippingGeometry", "NO_MAINTAIN_EXTENT")
print 'Clipped {0}'.format(os.path.basename(raster))
outputList.append(out_raster) # aopend all the output to the container
# compute the sum of all rasters with ignore no data option
sumRaster = CellStatistics(outputList, "SUM", "DATA")
sumRaster.save(r'F:\2014_05\Python Clipping\out\Statistic\ofsumrasters.tif') # remove .tif if GRID format is desired
print "Created Sum Raster"
if __name__ == '__main__':
main()
