<?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: How to make a layer from data? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1341026#M69270</link>
    <description>&lt;P&gt;No,&lt;/P&gt;&lt;P&gt;I use PyCharm. I really dislike using the Python features within ArcGIS Pro (either the window or notebooks) because they are exceedingly fragile and frequently cause the entire program to crash which I find unacceptable. It also has very limited debugging features.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the moveLayer method within the Map object and that seems to work for me:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        if county_name not in [x.name for x in maps]:
            m = aprx.createMap(county_name)

            m.addDataFromPath(county_fc)
            m.addDataFromPath(huc_fc)
            m.addDataFromPath(nhd_fc)

            layers = m.listLayers()

            for lyr in layers:
                if lyr.name.lower() == "nhd":
                    nhd_layer = lyr
                if lyr.name.lower() == "huc":
                    huc_layer = lyr
                if lyr.name.lower() == "county_boundaries":
                    county_layer = lyr

            m.moveLayer(county_layer, huc_layer, "BEFORE")
            m.moveLayer(county_layer, nhd_layer, "AFTER")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Oct 2023 17:28:24 GMT</pubDate>
    <dc:creator>ccowin_odfw</dc:creator>
    <dc:date>2023-10-24T17:28:24Z</dc:date>
    <item>
      <title>How to make a layer from data?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1340653#M69268</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to use the Map object method to add a layer to the map, but I can't for the life of me figure out how to make a Layer object to be added. I've tried to use the addDataFromPath method but that doesn't put the data in the order that I want it. I tried to use Make Feature Layer (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-feature-layer.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-feature-layer.htm&lt;/A&gt;) but that doesn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I use AddLayer from data in a GDB so it is added in the order I want it added?&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 19:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1340653#M69268</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-10-23T19:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a layer from data?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1340697#M69269</link>
      <description>&lt;P&gt;Have you tried running your commands in a python window in Pro? When I do this it automatically adds the layer to the map though not where I necessarily want it to go:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
env = arcpy.env.workspace r'path to geodatabase'
fc = 'Parcels' # name of a a featureclass in the gdb referenced above as my workspace
arcpy.management.MakeFeatureLayer(fc,'New County Parcels')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are doing this from a script, I think you need to look into the arcpy.mp documentation (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm" target="_self"&gt;Arcpy Mapping Module (arcpy.mp)&lt;/A&gt;&amp;nbsp;, especially the 'Map' classes. Especially look at the Code Example 1 below.. that shows how to insert a layer file where you want it to go, but I think it&amp;nbsp; would be similar to adding a layer created using the MakeFeatureLayer tool.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm" target="_self"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 21:17:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1340697#M69269</guid>
      <dc:creator>clt_cabq</dc:creator>
      <dc:date>2023-10-23T21:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a layer from data?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1341026#M69270</link>
      <description>&lt;P&gt;No,&lt;/P&gt;&lt;P&gt;I use PyCharm. I really dislike using the Python features within ArcGIS Pro (either the window or notebooks) because they are exceedingly fragile and frequently cause the entire program to crash which I find unacceptable. It also has very limited debugging features.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the moveLayer method within the Map object and that seems to work for me:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        if county_name not in [x.name for x in maps]:
            m = aprx.createMap(county_name)

            m.addDataFromPath(county_fc)
            m.addDataFromPath(huc_fc)
            m.addDataFromPath(nhd_fc)

            layers = m.listLayers()

            for lyr in layers:
                if lyr.name.lower() == "nhd":
                    nhd_layer = lyr
                if lyr.name.lower() == "huc":
                    huc_layer = lyr
                if lyr.name.lower() == "county_boundaries":
                    county_layer = lyr

            m.moveLayer(county_layer, huc_layer, "BEFORE")
            m.moveLayer(county_layer, nhd_layer, "AFTER")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 17:28:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-make-a-layer-from-data/m-p/1341026#M69270</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-10-24T17:28:24Z</dc:date>
    </item>
  </channel>
</rss>

