<?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: looping through rasters in an mxd in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123030#M9561</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Interesting, what does your output look like?&amp;nbsp; Yes, the Z component comes into play.&amp;nbsp; Depending on your rasters, there could be a great many more vertices that are stored...and the possibility of multipart features.&amp;nbsp; You could try generalizing if that more satisfactorily meets your end purpose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh, also, switch to 'line' out_geometry_type for the output - undoubtedly this will save on space as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RasterDomain_3d(raster, outPoly, "LINE")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Jan 2013 05:58:08 GMT</pubDate>
    <dc:creator>T__WayneWhitley</dc:creator>
    <dc:date>2013-01-21T05:58:08Z</dc:date>
    <item>
      <title>looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123021#M9552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all, newbie question here. I'd like to use the Python window to write a piece of code which loops through all the rasters in an mxd, and creates a polygon of the outline of each raster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Raster Domain tool in the 3D analyst extension works well for this task. However, when I try and use the code snippet in the Python window, I encounter the following problem. When I go to type in the In Raster ("dtm_grd") in the example below, I get a drop down list of all the rasters in my mxd. If I choose one from this list, I then get an error message that the raster "does not exist or is not supported". However, if I change the environment to the folder where the raster is currently located, and copy the source of the raster from the Properties box, the tool executes successfully. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way of looping through these layers, without having to manually change the address for each one? I know (very roughly) how to loop through a list of layers in python, but there doesn't seem much point trying if I can't get the Python snippet to work on even one layer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;nb not using the Raster to Polygon tool as most of the rasters are floating point and would need to be converted to integer before this tool would work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.CheckOutExtension("3D") env.workspace = "C:/data" arcpy.RasterDomain_3d("dtm_grd", "raster_domain.shp", "POLYGON")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 01:16:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123021#M9552</guid>
      <dc:creator>RosieBell</dc:creator>
      <dc:date>2013-01-14T01:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123022#M9553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is my best answer.&amp;nbsp; I am not an expert, but I try to answer someone's question when someone else helps me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would try to first use desc = arcpy.Describe(rasterLayer) to describe each raster layer in the map document.&amp;nbsp; See below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Describe/018v00000066000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Describe/018v00000066000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, I would try to use the desc.dataElement property of the layer describe object to get the raster dataset describe object.&amp;nbsp; See here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer_properties/018v00000063000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer_properties/018v00000063000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Lastly, I think you could use desc.dataElement.CatalogPath to get the source of the raster.&amp;nbsp; See here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Describe_object_properties/018v00000013000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Describe_object_properties/018v00000013000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, you could use it directly as an argument to RasterDomain without setting the workspace.&amp;nbsp; It sounds like you have various source folders for the raster datasets and you care specifically about the rasters in an MXD.&amp;nbsp; I don't know how you were planning on listing the layers, but I am assuming you would have to use the arcpy.mapping module instead of arcpy.ListRasters().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 04:21:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123022#M9553</guid>
      <dc:creator>NathanHeick</dc:creator>
      <dc:date>2013-01-14T04:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123023#M9554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lst = arcpy.mapping.ListLayers(mxd,"*")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for l in lst:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print l.isRasterLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have fun&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 04:27:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123023#M9554</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2013-01-14T04:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123024#M9555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you call the Describe function on each raster, you can get the Extent from the Describe properties, which returns an array of the coordinates defining the extent. You can pass that as an array to create a new polygon geometry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dsc = arcpy.Describe(raster)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;xmin = dsc.Extent.XMin&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ymin = dsc.Extent.YMin&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;xmax = dsc.Extent.XMax&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ymax = dsc.Extent.YMax&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;then use the code in the Polygon documentation to create a new shape for each raster&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Polygon/018z00000061000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Polygon/018z00000061000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dustin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 22:33:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123024#M9555</guid>
      <dc:creator>DustinEdge</dc:creator>
      <dc:date>2013-01-15T22:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123025#M9556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks to everyone for taking the time to help out. Unfortunately, I'm still not quite clear on how to achieve this - but this is a reflection on my skill level, rather than your help! I'll keep playing with it, and hopefully understand it soon. Cheers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 02:23:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123025#M9556</guid>
      <dc:creator>RosieBell</dc:creator>
      <dc:date>2013-01-18T02:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123026#M9557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This may help you, see the code...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/74002-Create-index-outline-of-rasters?p=258761#post258761" rel="nofollow" target="_blank"&gt;http://forums.arcgis.com/threads/74002-Create-index-outline-of-rasters?p=258761#post258761&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I get around to it, I intend to update it to arcpy and improve it, make a more universal tool out of it....later, when there's more free time.&amp;nbsp; But the basic scripting is there.&amp;nbsp; Guess if you're still having trouble I could make a finished tool out of it over the weekend for you to use, since I've been meaning to do it anyway.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 05:01:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123026#M9557</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-01-18T05:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123027#M9558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Wayne, thanks very much for your reply. I actually got it to work - this is the longest piece of code that I've ever used so quite exciting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've posted the v10 version of your code below - all credit to Wayne and none to me btw! The only other differences apart from v9/ v10 stuff was that I designed this to be loaded from the Python window, for the shameful reason that I don't know how to do it any other way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Script to loop through rasters in an mxd, and print a shape file of their extent.
# Based on script at the following forum link: http://forums.arcgis.com/threads/74002-Create-index-outline-of-rasters?p=258761#post258761


mxd = arcpy.mapping.MapDocument("CURRENT")
GridName = "boundaries"
IMAGEfldLen = 50
arcpy.CreateFeatureclass_management("&amp;lt;file path for directory which will contain shapefile&amp;gt;", "&amp;lt;insert name of shapefile&amp;gt;", "POLYGON")
fields = ['IMAGE', 'XMIN', 'XMAX', 'YMIN', 'YMAX']
arcpy.AddField_management("&amp;lt;insert name of shapefile&amp;gt;", fields[0], "TEXT", '', '', IMAGEfldLen)

for i in range(1,5):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(GridName, fields&lt;I&gt;, "DOUBLE", 18, 17)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "added field: " + fields&lt;I&gt;

rasters = arcpy.mapping.ListLayers(mxd)
arrayObj = arcpy.CreateObject('Array')
outRows = arcpy.InsertCursor(GridName)

for raster in rasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; extent = arcpy.Describe(raster).extent
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayObj.add(extent.lowerleft)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayObj.add(extent.lowerright)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayObj.add(extent.upperright)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayObj.add(extent.upperleft)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayObj.add(extent.lowerleft)
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = outRows.newRow()
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.Shape = arrayObj
&amp;nbsp;&amp;nbsp;&amp;nbsp; image = '.\\' + str(raster)
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue('IMAGE', image)
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue('XMIN', extent.xmin)
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue('YMIN', extent.ymin)
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue('XMAX', extent.xmax)
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat.setValue('YMAX', extent.ymax)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outRows.insertRow(feat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arrayObj.removeAll()

del outRows&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;nb in the resulting shapefile, I ended up with an extra row called 'boundaries' (name of my shapefile) which was a polygon which covered the entire area of any rasters. Not sure how I managed that, but I just deleted it anyway.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After all that effort, I've decided I really need to have a polygon that shows the exact boundary of each raster (not just a rectangle) so I'll keep working on it - if I achieve it I'll also post that code on this thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh and a quick qu for Wayne - why is the range 1 to 5? Cheers.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123027#M9558</guid>
      <dc:creator>RosieBell</dc:creator>
      <dc:date>2021-12-11T07:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123028#M9559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Rosie, that's great you got it working!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The reason I indexed the list iteration 1-5 is so that the looping for the double type fields (to hold X- and Y- min/max coord vals) starts at index 1 (item 2 in the list) and ends at index 4 (item 5 in the list), meaning index 0 is skipped.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I reserved the index 0 position in the list for the text type field, IMAGE.&amp;nbsp; Although it could very well have been written differently to handle creating the fields all in the same loop (such as with a dictionary to 'look up' the field type) and maybe I should have done this if for no other reason than to make the code more 'readable', I simply handled the single text field creation in the line prior to entering the loop (fields[0] is IMAGE):&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
gp.AddField_management(GridName, fields[0], 'TEXT', '', '', IMAGEfldLen)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this helps, this is how it would be to loop on the entire list:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; fields = ['IMAGE', 'XMIN', 'XMAX', 'YMIN', 'YMAX']
&amp;gt;&amp;gt;&amp;gt; for i in range(0, 5):&amp;nbsp; # or for i in range(5):
 print fields&lt;I&gt;

 
IMAGE
XMIN
XMAX
YMIN
YMAX
&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...but, then, if accessing the entire list that way it could be done without specifying the index variable i, simply:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; for field in fields:
 print field

 
IMAGE
XMIN
XMAX
YMIN
YMAX
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&amp;nbsp; Again, I'm glad you found that useful!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123028#M9559</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T07:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123029#M9560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Wayne, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for that and I think I understand it now &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW I did manage to get a script working for getting the exact outline for the rasters &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Script to loop through rasters in an mxd, and print a shape file of their extent (exact boundary, not just polygon).

import arcpy

from arcpy import env

arcpy.CheckOutExtension("3D")

mxd = arcpy.mapping.MapDocument(r"J:\gisprojects\Project\330\80000_89999\3308480_SS_GIS\0051_LiDAR_Index\mxd\ras_to_polygon_test.mxd")

env.workspace = r"J:\gisprojects\Project\330\80000_89999\3308480_SS_GIS\0051_LiDAR_Index\data\shpfile_ras_boundaries"
rasters = arcpy.mapping.ListLayers(mxd)

for raster in rasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Generate a unique name for each polygon
&amp;nbsp;&amp;nbsp;&amp;nbsp; outPoly = "domain_" + str(raster) + ".shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Execute Raster Domain Tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterDomain_3d(raster, outPoly, "POLYGON")
print "finished"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Only problem now is that they are very big, I'm guessing because it's looking for 3D values? Each polygon is about 8MB, and I only need the outline. Does anyone know how I can alter this, in the environments perhaps....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Rosie&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123029#M9560</guid>
      <dc:creator>RosieBell</dc:creator>
      <dc:date>2021-12-11T07:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123030#M9561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Interesting, what does your output look like?&amp;nbsp; Yes, the Z component comes into play.&amp;nbsp; Depending on your rasters, there could be a great many more vertices that are stored...and the possibility of multipart features.&amp;nbsp; You could try generalizing if that more satisfactorily meets your end purpose.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh, also, switch to 'line' out_geometry_type for the output - undoubtedly this will save on space as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RasterDomain_3d(raster, outPoly, "LINE")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 05:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123030#M9561</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-01-21T05:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123031#M9562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I added this to the beginning of my code to&amp;nbsp; disable M and Z values:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#disable M and Z values in output
arcpy.env.outputZflag = "Disabled"
arcpy.env.outputMflag = "Disabled"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;unfortunately it didn't affect the size. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also tried using the tool manually and disabling everything I could think of in the environments - again, didn't make any difference.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Saving it as LINE rather than POLYGON did the trick though! Thanks Wayne &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Now I wonder if I should bother trying to convert this line to polygon through my script, or if it's not necessary.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123031#M9562</guid>
      <dc:creator>RosieBell</dc:creator>
      <dc:date>2021-12-11T07:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123032#M9563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, depends what you need it for.&amp;nbsp; I would say now that you have it in line form, you can experiment with some of the generalization tools....because if you don't need vertices so 'densely packed', you can make some adjustments now, saving time in the conversion to polygon process - should you decide you need polygons.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don't know how well this will work, but it may be worth looking into:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Simplify Line (Cartography) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » Tool reference » Cartography toolbox&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Simplify_Line/007000000010000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Simplify_Line/007000000010000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just curious, but did you know you could export that extent raster polygon fc to a table and use that result in ArcMap as a 'legacy' raster catalog?&amp;nbsp; In other words, in table form, ArcMap reads and recognizes the IMAGE, XMIN, YMIN, XMAX, YMAX format as a catalog and will auto-load your image tiles (in the view extent - and this is adjustable).&amp;nbsp; I find that valuable sometimes, esp. when sharing multiple images without preprocessing a mosaic, etc.&amp;nbsp; That is, 10.0 still 'recognizes' it; I don't know about 10.1, but I wouldn't be surprised if it still is supported.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 01:02:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123032#M9563</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-01-22T01:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: looping through rasters in an mxd</title>
      <link>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123033#M9564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ah, I'm with you now. I hadn't realised that my polygon (and line) had so many vertices - about 50,000! Simplifying brought it down to under 20, much more manageable. I think I do need the polygons so have gone back to using POLYGON in the Raster Domain tool, and then simplifying.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my script to date (just in case anyone is trying something similar). It's a bit clumsy but it works. I included Delete_management to get rid of my large polygons, once I had a simplified version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Script to loop through rasters in an mxd, and print a shape file of their extent (exact boundary, not rectangle).

import arcpy
from arcpy import env

#disable M and Z values in output
arcpy.env.outputZflag = "Disabled"
arcpy.env.outputMflag = "Disabled"

arcpy.CheckOutExtension("3D")

mxd = arcpy.mapping.MapDocument(&amp;lt;insert path to mxd here&amp;gt;)

env.workspace = &amp;lt;insert path to workspace here&amp;gt;(mxd, "_*")

for raster in rasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Generate a unique name for each polygon/ shapefile. Have given them the prefix "del" so I can find them and delete them later
&amp;nbsp;&amp;nbsp;&amp;nbsp; outPoly = "del" + str(raster) + ".shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Execute Raster Domain Tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterDomain_3d(raster, outPoly, "POLYGON")

#get the feature classes from this folder
fcList = arcpy.ListFeatureClasses()

for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Generate a unique name for each simplified polygon
&amp;nbsp;&amp;nbsp;&amp;nbsp; simpPoly = fc.lstrip("del_")+ "simp_" + fc.rstrip(".shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Execute Simplify Polygon tool
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SimplifyPolygon_cartography(fc, simpPoly, "POINT_REMOVE", 1, "", "", "NO_KEEP")

#get feature classes for deletion from same folder
deleteBigPolys = arcpy.ListFeatureClasses("del*")

#delete these features classes (too large)
for deleteBigPoly in deleteBigPolys:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(deleteBigPoly)


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:04:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/looping-through-rasters-in-an-mxd/m-p/123033#M9564</guid>
      <dc:creator>RosieBell</dc:creator>
      <dc:date>2021-12-11T07:04:54Z</dc:date>
    </item>
  </channel>
</rss>

