<?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: Get smallest extent from a list of rasters in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449928#M35234</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See the arcpy &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v0000003w000000" rel="nofollow" target="_blank"&gt;ListRasters&lt;/A&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Describe/018v00000066000000/" rel="nofollow" target="_blank"&gt;Describe&lt;/A&gt;&lt;SPAN&gt; methods.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically loop through the rasters in the workspace and describe them to get the extent and calculate the minimum.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And here's an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; # Set the current workspace arcpy.env.workspace = "c:/data/DEMS"&amp;nbsp; # Get the list of rasters in the workspace rasters = arcpy.ListRasters()&amp;nbsp; for raster in rasters: &amp;nbsp;&amp;nbsp;&amp;nbsp; ext=arcpy.Describe(raster).extent &amp;nbsp;&amp;nbsp;&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmin=max(xmin,ext.XMin) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ymin=max(ymin,ext.XMax) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmax=min(xmax,ext.YMin) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ymax=min(ymax,ext.YMax) &amp;nbsp;&amp;nbsp;&amp;nbsp; except NameError: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmin,ymin,xmax,ymax=ext.XMin, ext.XMax, ext.YMin, ext.YMax &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; minext=[xmin,ymin,xmax,ymax]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 23 Jun 2013 00:47:02 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2013-06-23T00:47:02Z</dc:date>
    <item>
      <title>Get smallest extent from a list of rasters</title>
      <link>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449927#M35233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am completely lost here, I am trying to get the smallest extent of a raster from a list of rasters, if I set my workspace, and then use &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.extent = "MINOF"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Extent is: " + str(arcpy.env.extent)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get an output:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Extent is "MINOF".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try to set MINOF as an Extent variable (i.e. arcpy.env.extent = Extent("MINOF")&amp;nbsp; ), I get 0 0 0 0 NaN NaN etc etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't find on any forum an idea to help me get the smallest extent of all of the rasters in my directory or rasterList.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Jun 2013 14:11:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449927#M35233</guid>
      <dc:creator>AndrewDavies</dc:creator>
      <dc:date>2013-06-22T14:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get smallest extent from a list of rasters</title>
      <link>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449928#M35234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See the arcpy &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v0000003w000000" rel="nofollow" target="_blank"&gt;ListRasters&lt;/A&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Describe/018v00000066000000/" rel="nofollow" target="_blank"&gt;Describe&lt;/A&gt;&lt;SPAN&gt; methods.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically loop through the rasters in the workspace and describe them to get the extent and calculate the minimum.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And here's an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; # Set the current workspace arcpy.env.workspace = "c:/data/DEMS"&amp;nbsp; # Get the list of rasters in the workspace rasters = arcpy.ListRasters()&amp;nbsp; for raster in rasters: &amp;nbsp;&amp;nbsp;&amp;nbsp; ext=arcpy.Describe(raster).extent &amp;nbsp;&amp;nbsp;&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmin=max(xmin,ext.XMin) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ymin=max(ymin,ext.XMax) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmax=min(xmax,ext.YMin) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ymax=min(ymax,ext.YMax) &amp;nbsp;&amp;nbsp;&amp;nbsp; except NameError: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmin,ymin,xmax,ymax=ext.XMin, ext.XMax, ext.YMin, ext.YMax &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; minext=[xmin,ymin,xmax,ymax]&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 23 Jun 2013 00:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449928#M35234</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2013-06-23T00:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get smallest extent from a list of rasters</title>
      <link>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449929#M35235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Very many thanks for your help, I had thought that the "MINOF" command was meant to set as the minimum of all inputs in a workspace, it's not very clear on the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 08:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449929#M35235</guid>
      <dc:creator>AndrewDavies</dc:creator>
      <dc:date>2013-06-24T08:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Get smallest extent from a list of rasters</title>
      <link>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449930#M35236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I had thought that the "MINOF" command was meant to set as the minimum of all inputs in a workspace, it's not very clear on the help.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;No MINOF tells ArcPy to set the output extent to the minimum extent of input datasets when running a geoprocessing operation, not all datasets in a workspace. If you wanted to run a raster calculation, setting arcpy.env.extent = "MINOF" would make arcpy perform the calculation only on the area where the extents of the input rasters overlap.&amp;nbsp; If you printed arcpy.env.extent, you'd still get "MINOF", but if you described the output raster and printed its extent you'd see the actual minimum extent.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If your question is answered, can you click the check mark to the right of the best answer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jun 2013 19:35:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-smallest-extent-from-a-list-of-rasters/m-p/449930#M35236</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2013-06-24T19:35:48Z</dc:date>
    </item>
  </channel>
</rss>

