Greetings,
I'm very new to Python having just taken ESRI's 3-day Python scripting course.
I'm trying to clip a large raster into smaller rasters that are the size of DOQQs. I found some code that compares raster extents, then if the extents intersect, it clips the raster.
My code has issues with this line: "If DOQQExtent.within(TargetRasterExtent.extent):" This is my complete code:
Any idea what's wrong with the line?
Thanks for any help and Happy Thanksgiving!
Jonathan Mulder
California Departement of Water Resources
I'm very new to Python having just taken ESRI's 3-day Python scripting course.
I'm trying to clip a large raster into smaller rasters that are the size of DOQQs. I found some code that compares raster extents, then if the extents intersect, it clips the raster.
My code has issues with this line: "If DOQQExtent.within(TargetRasterExtent.extent):" This is my complete code:
Code:
import arcpy
# Get directories of DOQQ images
in_raster = arcpy.GetParameterAsText(0)
in_directories = arcpy.GetParameterAsText(1)
out_raster = arcpy.GetParameterAsText(2)
TargetRasterExtent = arcpy.Describe(in_raster).extent
for CurrentDirectory in in_directories:
DOQQRasters = arcpy.ListFiles("*.tif")
for CurrentRaster in CurrentDirectory:
DOQQExtent = arcpy.Describe(CurrentRaster).extent
If DOQQExtent.within(TargetRasterExtent.extent):
# if arcpy.Describe(CurrentRaster).extent.overlaps(TargetRasterExtent) == 'True':
print "Extent Overlaps"
Thanks for any help and Happy Thanksgiving!
Jonathan Mulder
California Departement of Water Resources