<?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: Describe Extent of Raster Outside of ArcMap in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593762#M46530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to both of you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Very helpful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Colin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 May 2014 11:21:13 GMT</pubDate>
    <dc:creator>ColinStief1</dc:creator>
    <dc:date>2014-05-14T11:21:13Z</dc:date>
    <item>
      <title>Describe Extent of Raster Outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593759#M46527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to understand the help files, and I am seeing that using arcpy.Describe(object) applies to layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I'm trying to do is loop through a large folder of raster files outside of ArcMap and grab their extent. My first thought was to use the Describe method, but if it applies only to layer files, that means I'd have to create a layer file (temp or not) for 900+ rasters, which is not ideal. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any other method I could use that doesn't involve geoprocessing to grab the extent of raster data sitting in a folder outside of ArcMap using arcpy?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Colin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 May 2014 14:41:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593759#M46527</guid>
      <dc:creator>ColinStief1</dc:creator>
      <dc:date>2014-05-12T14:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Describe Extent of Raster Outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593760#M46528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Derscribe works on rasters too but just use arcpy.GetRasterProperties_management method to get extents.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

ws = r'C:\MyDir\MyFGDB.gdb'
arcpy.env.workspace = ws
rasters = arcpy.ListRasters()
for raster in rasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(raster)
&amp;nbsp;&amp;nbsp;&amp;nbsp; nam = desc.name
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Results for " + str(nam)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; result_top = arcpy.GetRasterProperties_management(raster, "TOP")
&amp;nbsp;&amp;nbsp;&amp;nbsp; result_bot = arcpy.GetRasterProperties_management(raster, "BOTTOM")
&amp;nbsp;&amp;nbsp;&amp;nbsp; result_left = arcpy.GetRasterProperties_management(raster, "LEFT")
&amp;nbsp;&amp;nbsp;&amp;nbsp; result_right = arcpy.GetRasterProperties_management(raster, "RIGHT")

&amp;nbsp;&amp;nbsp;&amp;nbsp; print "extent top: " + str(result_top)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "extet bottom: " + str(result_bot)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "extent left" + str(result_left)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "extent right" + str(result_right)

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593760#M46528</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-12T01:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Describe Extent of Raster Outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593761#M46529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There's 3 ways to do it. I think #1 will be the fastest though...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#1
rasterPath = r"C:\temp\test.img"
rstObj = arcpy.Raster(rasterPath)
xmin, ymin, xmax, ymax = rstObj.extent.XMin, rstObj.extent.YMin, rstObj.extent.XMax, rstObj.extent.YMax

#2
rasterPath = r"C:\temp\test.img"
dscObj = arcpy.Describe(rasterPath)
xmin, ymin, xmax, ymax = dsc.extent.XMin, dscObj.extent.YMin, dscObj.extent.XMax, dscObj.extent.YMax

#3
rasterPath = r"C:\temp\test.img"
xmin = float(arcpy.GetRasterProperties_management(raster, "LEFT").getOutput(0))
ymin = float(arcpy.GetRasterProperties_management(raster, "BOTTOM").getOutput(0))
xmax = float(arcpy.GetRasterProperties_management(raster, "RIGHT").getOutput(0))
ymax = float(arcpy.GetRasterProperties_management(raster, "TOP").getOutput(0))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:30:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593761#M46529</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-12T01:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Describe Extent of Raster Outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593762#M46530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to both of you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Very helpful.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Colin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 May 2014 11:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593762#M46530</guid>
      <dc:creator>ColinStief1</dc:creator>
      <dc:date>2014-05-14T11:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Describe Extent of Raster Outside of ArcMap</title>
      <link>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593763#M46531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure this is long since resolved, but here goes anyway...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is another way to skin this cat, and maybe one or two more cats.&amp;nbsp; It seems to me that with 9.3, accessing some info got harder, or at least requires a little more code.&amp;nbsp; Since I'm a terrible typist, and therefore begrudge every line of code I have to type, I searched for path of lesser resistance.&amp;nbsp; I reverted to calling the 9.2 geoprocessor.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, calling the Clip_management tool:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import arcpy, arcgisscripting&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;gp2 = arcgisscripting.create()&amp;nbsp; ## the 9.2 geoprocessor&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;temperatureRaster = "Y:\\Connectivity\\temperature\\fut_mean_temp.tif"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;tempDir = "Y:\\Connectivity\\scratch"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;fc = 'cora_expert_CAT_buffer_2015Aug19.shp'&amp;nbsp; ## &lt;/STRONG&gt;&lt;EM&gt;in my current workspace&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;gp.Clip_management(temperatureRaster,gp2.describe(fc).extent,tempDir + "\\tmpTemperature.tif","layer","#","ClippingGeometry")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a bunch of stuff from my specific situation that I've left out that's irrelevant, but the point is you can still call the older geoprocessors and use them to pass info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So to get all the extents, even if using ArcGIS 10.3:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import arcpy &lt;/STRONG&gt;&lt;EM&gt;(if you want)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import arcgisscripting&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.env.overwriteOutput = True ## &lt;/STRONG&gt;&lt;EM&gt;and any other environments you want&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;gp2 = arcgisscripting.create() &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.env.workspace = "C://rasterDirectory"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;for raster in arcpy.ListDatasets():&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raster, gp2.describe(raster).extent&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That should print them all out.&amp;nbsp; And in string format, so no casting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another place I've found this useful is with getCount_management.&amp;nbsp; With 9.3 and higher this returns an object.&amp;nbsp; If you revert to 9.2 with the above approach, it'll still return an integer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry if it's too little, too late, rambling or if anything is missing.&amp;nbsp; Also, I don't know how to post code, so it might also look like crap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Aug 2015 23:31:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/describe-extent-of-raster-outside-of-arcmap/m-p/593763#M46531</guid>
      <dc:creator>CurtisBelyea1</dc:creator>
      <dc:date>2015-08-26T23:31:46Z</dc:date>
    </item>
  </channel>
</rss>

