I am trying to clip a shapefile based on the extents of a smaller raster. I find the extent of the raster using this code:
Extents = arcpy.sa.Raster(MyRaster).extent`
Then, I use these lines to make a polygon out of these extents:
pnt_array = arcpy.Array()
pnt_array.add(Extents2.lowerLeft)
pnt_array.add(Extents.lowerRight)
pnt_array.add(Extents.upperRight)
pnt_array.add(Extents.upperLeft)
poly = arcpy.Polygon(pnt_array)
Finally, I cut clip my shapefile using this code
arcpy.Clip_analysis(shp, poly, Shp_clip)
The problem is that I am using accuracy in two places. Please take a look:
Extents.XMax = -86.22649016383502
poly.extent.XMax = -86.22650146484375
arcpy.Describe(Shp_clip).extent.XMax= -86.22650146517043
Is there anyway that I can get a clipped shapefile with the extent exactly as Extents
?