I have seen a few questions with this error, but none of the fixes worked for me.
I am trying to use the clipping data management tool to clip raster files to a shapefile of polygons. I have also tried to do the same thing with the Extract by Mask tool and I got the same error.
This is the error: ERROR 000732: Output Extent: Dataset PerRanktop10percentTPA2001.shp does not exist or is not supported
Failed to execute (Clip).
The error says that the shapefile PerRanktop10percentTPA2001.shp does not exist, but when I use the print statement in line 39 it prints out this file, so it definitely exists and the script can find it.
Hope someone can help!
Here's my code:
<SPAN class="comment token">#import necessary packages</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> os
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="comment token">#sets workspace to ADS folder</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/ADS/ADS_PerRanktop10percentTPA2001"</SPAN>
<SPAN class="comment token">#turns overwrite on</SPAN>
env<SPAN class="punctuation token">.</SPAN>overwriteOuput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token">#lists shapefiles</SPAN>
shapefiles <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>shapefiles<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#changes year to match ADS year</SPAN>
shapefile <SPAN class="operator token">=</SPAN> shapefiles<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
year <SPAN class="operator token">=</SPAN> shapefile <SPAN class="punctuation token">[</SPAN><SPAN class="number token">22</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">26</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>year<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#sets workspace to rasters folder</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/RGI/RGI_2000_2003"</SPAN>
env<SPAN class="punctuation token">.</SPAN>overwriteOuput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token">#Lists folders in workspace</SPAN>
folders <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListWorkspaces<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> folder <SPAN class="keyword token">in</SPAN> folders<SPAN class="punctuation token">:</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> folder
env<SPAN class="punctuation token">.</SPAN>overwriteOuput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token">#lists rasters in all folers</SPAN>
rasters <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListRasters<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"tif"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>rasters<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> raster <SPAN class="keyword token">in</SPAN> rasters<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#Names inputs and outputs for each raster in each folder</SPAN>
in_raster <SPAN class="operator token">=</SPAN> rasters<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
in_template_dataset <SPAN class="operator token">=</SPAN> shapefiles<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
out_raster <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"clip_ads_"</SPAN> <SPAN class="operator token">+</SPAN> year <SPAN class="operator token">+</SPAN> raster<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"."</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">".tif"</SPAN><SPAN class="punctuation token">)</SPAN>
output_path <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Z:/Fall2016_GlacierNationalParkClimate/Term2/Charlotte/RGI_ADS_clip_output"</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>in_template_dataset<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#runs clip data management </SPAN>
clip <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Clip_management<SPAN class="punctuation token">(</SPAN>in_raster<SPAN class="punctuation token">,</SPAN> "<SPAN class="comment token">#", output_path + out_raster, in_template_dataset, "#", "ClippingGeometry","NO_MAINTAIN_EXTENT")</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>