Select to view content in your preferred language

Clip_management fails to Esri Land Cover map

267
3
10-04-2025 04:19 AM
ThomasMiller24
Emerging Contributor

Hello, 

I'm trying to clip a small section of ESRI Land Cover layer using a python script I'm developing, but I keep encountering a Error 99999 message. I have reduced the extent to the required size and that still doesn't work. It works fine when I run it from the Geoprocessing tools. Code snippet is below and I'm using ArcGIS Pro 3.5.3. Someone suggested REST services don't work in Pro but I've tried the non-REST link also and still no good. Any ideas where I might be going wrong? Thank you!!

Tom

transformed_extents = '-420353.6209754332 6857701.481562025 -394409.69783226284 6881148.42889701'

'PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],' \

'PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Mercator_Auxiliary_Sphere"],PARAMETER["False_Easting",0.0],' \
'PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",0.0],PARAMETER["Auxiliary_Sphere_Type",0.0],UNIT["Meter",1.0]]'
temp_output_raster1 = os.path.join(ScratchFolder, "step_2_8_temp_raster1.tif")
 
with arcpy.EnvManager(extent=transformed_extent):
            arcpy.Clip_management(input_rastertransformed_extentstemp_output_raster1maintain_clipping_extent="MAINTAIN_EXTENT")
0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

@ThomasMiller24 

transformed_extents =    # -- ends in s

with arcpy.EnvManager(extent=transformed_extent)  # -- no s

arcpy.Clip_management(input_raster, transformed_extents  # -- ends in s

 

it may have failed with the 99999 error because of the with statement


... sort of retired...
0 Kudos
ThomasMiller24
Emerging Contributor

Thanks for replying - good spot on the typo. 

Unfortunately, I wish it were that simple 😭 I think the above was because this editor converted the 😞 to a sad face and in editing it, I deleted the s by mistake.

 

That being said, I spotted another type:

arcpy.Clip_management(input_rastertransformed_extents_strtemp_output_raster1maintain_clipping_extent="MAINTAIN_EXTENT")

where transformed_extents_str = '-420353.6209754332 6857701.481562025 -394409.69783226284 6881148.42889701'

Sorry for any confusion

Either way, I'm still seeing the same error message  

 

0 Kudos
DanPatterson
MVP Esteemed Contributor

assuming the output coordinate system matches the input and the extents are correct, the only thing I could suggest for a try would be to hardcode the output path and use a different output filename in case overwriteOutputs isn't set to True.   Dump the 'with' portion as well.

If it works through the tool within Pro then your script will have to match the Environment settings for the script to work.

Good luck


... sort of retired...
0 Kudos