<?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: getting started with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731280#M56737</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well I feel stupid.&amp;nbsp; My script wasn't saved with a .py extension.&amp;nbsp; That solved the issue&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wade&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Aug 2011 14:36:53 GMT</pubDate>
    <dc:creator>WadeGivens</dc:creator>
    <dc:date>2011-08-09T14:36:53Z</dc:date>
    <item>
      <title>getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731274#M56731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, finally breaking down and trying to get going with Python.&amp;nbsp; My first attempt is to create a batch raster clip tool that loops through a set of rasters, clips them, and saves then to another directory with "_clip" appended to the file name.&amp;nbsp; The script below runs with no errors.&amp;nbsp; Problem is no results either.&amp;nbsp; Any ideas, or thoughts to get me going in the right direction?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
import os

inDIR = "C:/Temp/imagery"
outDIR = "C:/Temp/imagery/clipped"
clipFC = "C:/Temp/imagery/clip_feature.shp"

arcpy.env.workspace = inDIR

rasters = arcpy.ListRasters("*", "TIFF")

for raster in rasters:
 print raster
 outname = raster[:-4] + "_clip.tif"
 arcpy.Compression= "LZW"
 arcpy.Clip_Management(raster, "#", os.path.join(outDIR, raster), clipFC, "#", "ClippingGeometry")

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wade&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 03:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731274#M56731</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2011-08-09T03:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731275#M56732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe the problem is with the 'arcpy.ListRasters' function.&amp;nbsp; You will want to specify "TIF" instead of "TIFF".&amp;nbsp; Also, I believe you will want to specify 'os.path.join(OutDir, outname)' within the 'arcpy.Clip_management' function.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rasters = arcpy.ListRasters("*", "TIF")

for raster in rasters:
 print raster
 outname = raster[:-4] + "_clip.tif"
 arcpy.Compression= "LZW"
 arcpy.Clip_management(raster, "", os.path.join(outDIR, outname), clipFC, "", "ClippingGeometry")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731275#M56732</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T07:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731276#M56733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&amp;nbsp; That did the trick.&amp;nbsp; Been kinda hard to get going with some of this.&amp;nbsp; Lots of posts out there that give examples using gp. calls.&amp;nbsp; Not so many using arcpy.&amp;nbsp; Trying to get going with arcpy since that is preferred syntax now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wade&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 12:35:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731276#M56733</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2011-08-09T12:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731277#M56734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jake:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now that I have this going, I've added the script to a toolbox in ArcMap and I'm trying to pass the workspace directories and clip shape as parameters (see below).&amp;nbsp; I get the following error when trying to run the tool from the toolbox:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: Clip C:\Temp\imagery C:\Temp\imagery\clipped\clipped C:\Temp\imagery\all_corn_IMPACT_2011.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Aug 09 09:50:33 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script Clip...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000714: Error in script Clip.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Error in executing: cmd.exe /C C:\GIS_PR~1\PYTHON~1\BATCH_~1&amp;nbsp; "C:\Temp\imagery" "C:\Temp\imagery\clipped\clipped" "C:\Temp\imagery\all_corn_IMPACT_2011.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Clip).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Aug 09 09:50:33 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os

inDIR = arcpy.GetParameterAsText(0)
outDIR = arcpy.GetParameterAsText(1)
clipFC = arcpy.GetParameterAsText(2)

# inDIR = "C:/Temp/imagery"
# outDIR = "C:/Temp/imagery/clipped"
# clipFC = "C:/Temp/imagery/all_corn_IMPACT_2011.shp"

arcpy.env.workspace = inDIR

rasters = arcpy.ListRasters("*", "TIF")

for raster in rasters:
 print raster
 outname = raster[:-4] + "_clip.tif"
 arcpy.Compression= "LZW"
 arcpy.Clip_management(raster, "", os.path.join(outDIR, outname), clipFC, "", "ClippingGeometry")

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas on what may be causing this error?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wade&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731277#M56734</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2021-12-12T07:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731278#M56735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Make sure you have the correct data types setup for the parameters.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 14:14:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731278#M56735</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-08-09T14:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731279#M56736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Still getting the same error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: Script C:\GIS_Projects\2011\CE_BU_RS\RapidEye\Aug_1st_week\images\5_band C:\GIS_Projects\2011\CE_BU_RS\RapidEye\Aug_1st_week\images\5_band\clipped C:\GIS_Projects\2011\CE_BU_RS\RapidEye\shapefile_bnds\all_corn_IMPACT_2011.shp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Tue Aug 09 10:30:53 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Running script Script...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000714: Error in script Script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Error in executing: cmd.exe /C C:\GIS_PR~1\PYTHON~1\BATCH_~1&amp;nbsp; "C:\GIS_Projects\2011\CE_BU_RS\RapidEye\Aug_1st_week\images\5_band" "C:\GIS_Projects\2011\CE_BU_RS\RapidEye\Aug_1st_week\images\5_band\clipped" "C:\GIS_Projects\2011\CE_BU_RS\RapidEye\shapefile_bnds\all_corn_IMPACT_2011.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Script).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Tue Aug 09 10:30:53 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Screenshot of my script parameters attached.&amp;nbsp; I can copy and paste the paths into the script and it works fine&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy
import os

inDIR = arcpy.GetParameterAsText(0)
outDIR = arcpy.GetParameterAsText(1)
clipFC = arcpy.GetParameterAsText(2)

arcpy.env.workspace = inDIR

rasters = arcpy.ListRasters("*", "TIF")

for raster in rasters:
 print raster
 outname = raster[:-4] + "_clip.tif"
 arcpy.Compression= "LZW"
 arcpy.Clip_management(raster, "", os.path.join(outDIR, outname), clipFC, "", "ClippingGeometry")


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731279#M56736</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2021-12-12T07:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: getting started with Python</title>
      <link>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731280#M56737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well I feel stupid.&amp;nbsp; My script wasn't saved with a .py extension.&amp;nbsp; That solved the issue&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wade&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Aug 2011 14:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/getting-started-with-python/m-p/731280#M56737</guid>
      <dc:creator>WadeGivens</dc:creator>
      <dc:date>2011-08-09T14:36:53Z</dc:date>
    </item>
  </channel>
</rss>

