<?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: Clip a raster using the Clipping Geometry option using ArcPy not working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621214#M48351</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Sorry to revive an old question, but&amp;nbsp;in case anyone else is having this same issue and stumbles on this thread (like I just did), here's the solution: NoData has to be defined as "0" instead of "#". Using the code above, it should be:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.Clip_management(inputRaster, '#', outputRaster, footprints + '_temp', '0', 'ClippingGeometry')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That will allow the tool to clip to the polygon shape instead of the bounding rectangle.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Apr 2019 17:08:13 GMT</pubDate>
    <dc:creator>AaronZuspan1</dc:creator>
    <dc:date>2019-04-12T17:08:13Z</dc:date>
    <item>
      <title>Clip a raster using the Clipping Geometry option using ArcPy not working</title>
      <link>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621212#M48349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to automate the process of clipping rasters of scanned maps by following the recommendation found here:&amp;nbsp;&lt;A class="link-titled" href="http://support.esri.com/technical-article/000011116" title="http://support.esri.com/technical-article/000011116" rel="nofollow noopener noreferrer" target="_blank"&gt;How To: Clip a raster using the Clipping Geometry option&lt;/A&gt;. The rasters are being clipped to the envelope, but not the shape as pixels outside of the polygon are still persisting. The rasters and the feature class are in the same coordinate system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My footprints are all stored in same feature class with a field 'RasterFile' storing the raster name (e.g. 'raster01.tif'). I have tried creating a feature layer with a query and using Select analysis to select out the footprint for a single raster (see code below). Everything processes, but the shape clip is not honored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I just run the Raster Clip tool manually, the clip honors the shape. Any ideas for what I may be missing?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Paths have been generalized for example purposes&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

inputFolder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'..\RasterFolder'&lt;/SPAN&gt;
footprints &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'..\GDB.gbb\ScanFootprints'&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# Polygon feature class&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Create a list of rasters; Output will look like: ['raster01.tif', 'raster02.tif', ...]&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; inputFolder
processRasters &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListRasters&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Iterate each raster to clip&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; raster &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; processRasters&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputRaster &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;inputFolder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; raster&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# Feature layer method&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;footprints&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"footprint"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"RasterFile = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; raster &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Clip_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;inputRaster&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; '&lt;SPAN class="comment token"&gt;#', outputRaster, "footprint", '#', 'ClippingGeometry')&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# Select Analysis method&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Select_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;footprints&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; footprints &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'_temp'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"RasterFile = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; raster &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Clip_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;inputRaster&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; '&lt;SPAN class="comment token"&gt;#', outputRaster, footprints + '_temp', '#', 'ClippingGeometry')‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:29:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621212#M48349</guid>
      <dc:creator>James_Whitacre</dc:creator>
      <dc:date>2021-12-12T02:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Clip a raster using the Clipping Geometry option using ArcPy not working</title>
      <link>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621213#M48350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can find anything obviously wrong (with the exception of your outputRaster variable is not defined, but I'm guessing you left it out in the copy/paste.) and cannot duplicate your error.&amp;nbsp; I have a script tool that uses this and it has no issues.&amp;nbsp; The only difference is that I used clipping_geometry = 'ClippingGeometry' for my 6th parameter, but that shouldn't make any difference.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jan 2017 17:53:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621213#M48350</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-01-20T17:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Clip a raster using the Clipping Geometry option using ArcPy not working</title>
      <link>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621214#M48351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;Sorry to revive an old question, but&amp;nbsp;in case anyone else is having this same issue and stumbles on this thread (like I just did), here's the solution: NoData has to be defined as "0" instead of "#". Using the code above, it should be:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.Clip_management(inputRaster, '#', outputRaster, footprints + '_temp', '0', 'ClippingGeometry')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;That will allow the tool to clip to the polygon shape instead of the bounding rectangle.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Apr 2019 17:08:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/clip-a-raster-using-the-clipping-geometry-option/m-p/621214#M48351</guid>
      <dc:creator>AaronZuspan1</dc:creator>
      <dc:date>2019-04-12T17:08:13Z</dc:date>
    </item>
  </channel>
</rss>

