<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HELP ME PLEASE! Script to clip and ROI using a shape file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441136#M34578</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, clint.dow!!! I made some adjustments and actually got the image to clip, however it is not clipping to the polygon feature (like I need), it is clipping to the square of the polygon feature, even though I specified the "ClippingGeometry" tool. If you or anyone has any insight into how to now get that to work I would really appreciate it! Here is my current script: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;## Clip_management (in_raster, rectangle, out_raster, {in_template_dataset}, {nodata_value}, {clipping_geometry}) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace= r'D:\rmnp\SamSOrgNDVIData\ND 1989 - 1999\nd1996'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ClippingGeometry= "ClippingGeometry" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;out_raster= r'D:\rmnp\SamSOrgNDVIData\Test1996\\'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rastList= arcpy.ListRasters()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for rast in rastList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_management(rast, "#", 'out_raster' + rast[:-4] + '_Clipped.tif', 'D:\Shape File Buffer\RMNPBuff1km.shp', '#', "ClippingGeometry")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Mar 2014 14:14:15 GMT</pubDate>
    <dc:creator>SamanthaSmyth</dc:creator>
    <dc:date>2014-03-25T14:14:15Z</dc:date>
    <item>
      <title>HELP ME PLEASE! Script to clip and ROI using a shape file</title>
      <link>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441134#M34576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi! Please help me! I created a script a few weeks ago which would create an ROI using the clipping geometry tool from a shapefile. The script had originally worked and now will only error out. I cannot for the life of me figure out what went wrong. I'm very new to coding and non of my professors can help me to determine what is happening. Here is a copy of my script: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace= r'D:\rmnp\SamSOrgNDVIData\ND 1989 - 1999\nd1990'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;out_raster= r'D:\rmnp\SamSOrgNDVIData\Test1990\\'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rastList= arcpy.ListRasters()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for rast in rastList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_management(rast, "#", out_raster + rast[:-4] + 'Clipped.tif', 'D:\\Shape File Buffer\\RMNPBuff1km.shp', '#', "ClippingGeometry")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Every time I try to run it I get the error: Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "D:/fack.py", line 6, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_management(rast, "#", out_raster + rast[:-4] + 'Clipped.tif', 'D:\\Shape File Buffer\\RMNPBuff1km.shp', '#', "ClippingGeometry")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 12021, in Clip&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Clip).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Mar 2014 20:08:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441134#M34576</guid>
      <dc:creator>SamanthaSmyth</dc:creator>
      <dc:date>2014-03-24T20:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: HELP ME PLEASE! Script to clip and ROI using a shape file</title>
      <link>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441135#M34577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That "ExecuteError: ERROR 999999: Error executing function." usually means something isn't right with the input parameters for the geoprocessing tool in question. I would guess its probably the parameter: &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;out_raster + rast[:-4] + 'Clipped.tif'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The rast[:-4]&lt;/SPAN&gt;&lt;SPAN&gt; will only work if rast has an extension, if its a grid format raster it won't have a file extension. Perhaps try &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;out_raster + rast.split('.')[0] +'Clipped.tif'&lt;/SPAN&gt;&lt;SPAN&gt; instead. This will ensure you only get the name of the raster regardless of the file extension or lack thereof.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also in regards to your screen name, don't get discouraged! Its a bit of a learning curve and its great to come ask questions if you find yourself stuck rather than giving up &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 13:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441135#M34577</guid>
      <dc:creator>ClintDow</dc:creator>
      <dc:date>2014-03-25T13:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: HELP ME PLEASE! Script to clip and ROI using a shape file</title>
      <link>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441136#M34578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks, clint.dow!!! I made some adjustments and actually got the image to clip, however it is not clipping to the polygon feature (like I need), it is clipping to the square of the polygon feature, even though I specified the "ClippingGeometry" tool. If you or anyone has any insight into how to now get that to work I would really appreciate it! Here is my current script: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;## Clip_management (in_raster, rectangle, out_raster, {in_template_dataset}, {nodata_value}, {clipping_geometry}) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace= r'D:\rmnp\SamSOrgNDVIData\ND 1989 - 1999\nd1996'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ClippingGeometry= "ClippingGeometry" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;out_raster= r'D:\rmnp\SamSOrgNDVIData\Test1996\\'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rastList= arcpy.ListRasters()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for rast in rastList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_management(rast, "#", 'out_raster' + rast[:-4] + '_Clipped.tif', 'D:\Shape File Buffer\RMNPBuff1km.shp', '#', "ClippingGeometry")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 14:14:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441136#M34578</guid>
      <dc:creator>SamanthaSmyth</dc:creator>
      <dc:date>2014-03-25T14:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: HELP ME PLEASE! Script to clip and ROI using a shape file</title>
      <link>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441137#M34579</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the line &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.Clip_management(rast, "#", 'out_raster' + rast[:-4] + '_Clipped.tif', 'D:\Shape File Buffer\RMNPBuff1km.shp', '#', "ClippingGeometry")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should use a raw string instead of 'D:\Shape File Buffer\RMNPBuff1km.shp' -- that is,&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt; r'D:\Shape File Buffer\RMNPBuff1km.shp'&lt;/SPAN&gt;&lt;SPAN&gt; Right now without a raw string it probably can't find the shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;r&lt;/SPAN&gt;&lt;SPAN&gt; before the string tells it not to pay attention to the backslashes, which will behave differently if the string is not raw.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See here for more info on that concept: &lt;/SPAN&gt;&lt;A href="http://docs.python.org/release/2.5.2/ref/strings.html"&gt;http://docs.python.org/release/2.5.2/ref/strings.html&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2014 14:41:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-me-please-script-to-clip-and-roi-using-a/m-p/441137#M34579</guid>
      <dc:creator>ClintDow</dc:creator>
      <dc:date>2014-03-25T14:41:15Z</dc:date>
    </item>
  </channel>
</rss>

