Hello,
I have been struggling to get this part of a script to work. If I hard code the four coordinate pairs: like this:
rectangle = "-121.677618762735 42.7497214280392 -119.35205017646 45.3659860875993"
it works but we have to remember to change this every time we change study areas. When I run the script pasted below I get the following error:
Traceback (most recent call last):
File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript
exec codeObject in __main__.__dict__
File "C:\Documents and Settings\Administrator\Desktop\clip_test.py", line 13, in <module>
arcpy.Clip_management (raster, rectangle, outraster)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 7692, in Clip
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000840: The value is not a Envelope.
Failed to execute (Clip).
Here is my code:
import arcpy
arcpy.env.workspace = r"C:\Temp"
raster = "some_raster"
outraster = r"C:\output_raster"
extent = r"C:\GIS_Data\test_extent2.shp"
desc = arcpy.Describe(extent)
rectangle = desc.extent
print rectangle
# Clip_management (in_raster, rectangle, out_raster, {in_template_dataset}, {nodata_value}, {clipping_geometry})
arcpy.Clip_management (raster, rectangle, outraster)
print "Success!"
What am I missing?
Thanks!