<?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: Extent of in_memory layer/adding an in_memory layer to map in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014171#M59415</link>
    <description>&lt;P&gt;Perfect! Just had to change the CS to get it in the correct units!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jan 2021 02:43:03 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-01-06T02:43:03Z</dc:date>
    <item>
      <title>Extent of in_memory layer/adding an in_memory layer to map</title>
      <link>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014154#M59413</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get the extent of an in_memory layer from a standalone script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I'm having some issues running into this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason I can't add the in_memory layer to the map current map. See could below. the # are just different ways I've tried.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep getting an error saying&amp;nbsp;&lt;/P&gt;&lt;P&gt;s2 = map.listLayers('parcels_lyr')[0]&lt;BR /&gt;IndexError: list index out of range&lt;/P&gt;&lt;P&gt;I'm pretty sure that it can't find the layer. When I list the layers it is not in there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The goal is to export a map with the extent of a 2 mile buffer (in_memory layer) around the original boundary. So&amp;nbsp; it will show the original boundary with some room around all sides. But I don't want to show the buffered boundary, it's just to get the extent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;arcpy.analysis.Buffer(s,r"in_memory\buffer2","2 MILE")
arcpy.MakeFeatureLayer_management(r"in_memory\buffer2", "parcels_lyr")
for lyr in map.listLayers():
    arcpy.AddMessage(lyr.name)
s2 = map.listLayers('parcels_lyr')[0]
#map.addDataFromPath(r"in_memory\buffer2")
#map.insertLayer(s, r"in_memory\buffer2", "BEFORE")
#lyt.camera.setExtent(lyt.getLayerExtent(s2, False, True))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;ArcPro 2.5&amp;nbsp;python 3.x&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 23:28:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014154#M59413</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-05T23:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extent of in_memory layer/adding an in_memory layer to map</title>
      <link>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014164#M59414</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous User&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;It's documented &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/appendices/using-the-in-memory-output-workspace.htm#ESRI_SECTION1_6D5A4BA6A6AD489AA586FC503209F8D5" target="_blank" rel="noopener"&gt;here&lt;/A&gt; that when using the in_memory workspace with geoprocessing models, that the output needs to be written to disk to be displayed as a layer in the map - and while the documentation isn't explicit about this also applying to Python scripts, I suspect the same limitation would also apply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If however, our main interest in the in_memory buffer output is getting its extent&amp;nbsp; so we can use that to set the view extent for our map export&amp;nbsp; - I'd suggest we use a slightly different approach so that we can get the extent directly from the in_memory feature class, without having to create a layer&amp;nbsp; in the map. One such approach we could use for this purpose would be to use the arcpy.da.Describe function&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.analysis.Buffer(s,r"in_memory\buffer2","2 MILE")
buff_extent = arcpy.da.Describe(r"in_memory\buffer2")['extent']

# Use the buff_extent variable to set camera extent, then export the map ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 00:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014164#M59414</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-06T00:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Extent of in_memory layer/adding an in_memory layer to map</title>
      <link>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014171#M59415</link>
      <description>&lt;P&gt;Perfect! Just had to change the CS to get it in the correct units!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 02:43:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extent-of-in-memory-layer-adding-an-in-memory/m-p/1014171#M59415</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-01-06T02:43:03Z</dc:date>
    </item>
  </channel>
</rss>

