0

I want to clip the elevation data (3DEM) downloaded from USGS website. The raster-clip tool "Clip (data management)" in ArcGIS Pro works very well. However, I cannot clip it using the python function "arcpy.Clip_management()" .

The error report that the raster file is not exist or not support. I have tried different ways to read it, such as:

~grdn39w075.tif/Band_1 This is used by the Clip tool in Arcgis Pro ~grdn39w075.tif_Band_1 ~grdn39w075/Band_1

None of them can read the 3DEM file successfully.

Python code:

in_raster= "C:/Users/Desktop/Elevation/Tiles/grdn42w075.tif/Band_1"
for i in range(0,9):
 buffer = shp_list[i]
 out_id=num_buffer=re.findall('\d+', shp_list[i])
 out_path="C:/Users/Desktop/LUR_DM/GIS/Elevation/n42w75/"
 arcpy.Clip_management(in_raster,buffer,"n42w75_"+ out_id[1],
"C:/Users/Desktop/Documents/ArcGIS/Projects/LUR/LUR.gdb","99999","ClippingGeometry", "MAINTAIN_EXTENT")
  • ~/ means nothing in Windows, try using the full path including the drive letter – mikewatt Jan 30 at 20:57
  • Sorry about the confusion. I use the full path in my code. To protect the ID credential in our school, I use ~ to represent the first part of path. – Sara Jan 30 at 21:05
  • Ah, gotcha. To debug, print your output file path that you're building and make sure that looks valid. Try arcpy.Exists() on the input file to make sure that's getting found correctly – mikewatt Jan 30 at 21:46
  • I suggest deleting '~' and replacing it with some dummy pseudonym like C:/Users/SomeUser/, for clarity to other readers. – Paulo Raposo Jan 31 at 5:18
0

I think the problem is here:

.../grdn42w075.tif/Band_1

A .tif file, on the OS, is the end of a path, so /Band_1 doesn't make sense when Python tries to look for that path. If you're just going for that .tif file, simply delete /Band_1. All existing bands in the GeoTiff should get clipped by default by the Arc tool.

If grdn42w075.tif is in fact a directory, you might need to supply the file extension for the file Band_1. I suggest not naming your directories that way, and please use 4 spaces when indenting in Python :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.