1

I have have a directory that contains many of rasters. I also have a polygon shapefile with a single record that defines my area of interest (AOI). I would like to copy all rasters that fall within (or partially within) said AOI to a new directory)

Currently, my code is like this

#set up paths and get list of rasters
arcpy.env.workspace = r'\path\to\raster\dir'
rasters = arcpy.ListRasters()
AOI = r'\path\to\aoi.shp'

#get geometry of single polygon in shapefile
with arcpy.da.SearchCursor(AOI,['SHAPE@']) as cursor:
    for row in cursor: AOI_geom = row[0]

for raster in rasters:
    raster_extent = arcpy.Describe(raster).extent
    if raster_extent.overlaps(AOI_geom):
        #copy raster to new dir....

However, the extent.overlap() always returns false, even when I can see visually that there is an overlap

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Nick
  • 1,603
  • 4
  • 17

1 Answers1

0

My problem was simply that the spatial references were not the same. Thanks Michael Stimson

Nick
  • 1,603
  • 4
  • 17