<?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 changing layer order in contents programmatically (i.e. using arcpy) in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56604#M2362</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a python script that takes csv files, converts them into feature class and then adds them to the map. I am using ArcGIS Pro so the function used is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.management.XYTableToPoint(stabbings_in_table, stabbings_out_feature_class,stabbings_x_coords, stabbings_y_coords, stabbings_z_coords,arcpy.SpatialReference(2031))



&lt;/PRE&gt;&lt;P&gt;I run this code two more times for the other two csv files I have. So, in the end my Contents section of the map has three layers in total: Homicides, Shootings, Stabbings&lt;/P&gt;&lt;P&gt;From there I then create the service definition and upload it to our internal Portal.&lt;/P&gt;&lt;P&gt;Here is my problem.&lt;/P&gt;&lt;P&gt;No matter what order I create the feature classes the Contents pane always ends up listing them in alphabetical order, which then causes the service definition/feature service to list them in alphabetical order as well. The order I need is:&lt;/P&gt;&lt;P&gt;[0] Stabbings&lt;/P&gt;&lt;P&gt;[1] Shootings&lt;/P&gt;&lt;P&gt;[2] Homicides&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that inside of the actual map file you can click and drag on the layers to reorder them, but can this be done programmatically? My hope is that as long as the layers are in the order I need then they will stay in that order when the feature service is created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 15:58:25 GMT</pubDate>
    <dc:creator>MarkJones7</dc:creator>
    <dc:date>2021-12-12T15:58:25Z</dc:date>
    <item>
      <title>changing layer order in contents programmatically (i.e. using arcpy)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56604#M2362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a python script that takes csv files, converts them into feature class and then adds them to the map. I am using ArcGIS Pro so the function used is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.management.XYTableToPoint(stabbings_in_table, stabbings_out_feature_class,stabbings_x_coords, stabbings_y_coords, stabbings_z_coords,arcpy.SpatialReference(2031))



&lt;/PRE&gt;&lt;P&gt;I run this code two more times for the other two csv files I have. So, in the end my Contents section of the map has three layers in total: Homicides, Shootings, Stabbings&lt;/P&gt;&lt;P&gt;From there I then create the service definition and upload it to our internal Portal.&lt;/P&gt;&lt;P&gt;Here is my problem.&lt;/P&gt;&lt;P&gt;No matter what order I create the feature classes the Contents pane always ends up listing them in alphabetical order, which then causes the service definition/feature service to list them in alphabetical order as well. The order I need is:&lt;/P&gt;&lt;P&gt;[0] Stabbings&lt;/P&gt;&lt;P&gt;[1] Shootings&lt;/P&gt;&lt;P&gt;[2] Homicides&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that inside of the actual map file you can click and drag on the layers to reorder them, but can this be done programmatically? My hope is that as long as the layers are in the order I need then they will stay in that order when the feature service is created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 15:58:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56604#M2362</guid>
      <dc:creator>MarkJones7</dc:creator>
      <dc:date>2021-12-12T15:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: changing layer order in contents programmatically (i.e. using arcpy)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56605#M2363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try...&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/arcpy/mapping/alphabeticallistofclasses.htm" title="http://pro.arcgis.com/en/pro-app/arcpy/mapping/alphabeticallistofclasses.htm"&gt;Alphabetical list of arcpy.mp classes—ArcPy | ArcGIS Desktop&lt;/A&gt; specifically&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/arcpy/mapping/layerfile-class.htm" title="http://pro.arcgis.com/en/pro-app/arcpy/mapping/layerfile-class.htm"&gt;LayerFile—ArcPy | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but maybe if you set it up first and are using the same names, it might keep the order&lt;/P&gt;&lt;P&gt;I totally haven't tried this but I read about it here....&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/help/sharing/overview/introduction-to-sharing-web-layers.htm" title="http://pro.arcgis.com/en/pro-app/help/sharing/overview/introduction-to-sharing-web-layers.htm"&gt;Introduction to sharing web layers—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Preserve layer and table IDs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="416753" alt="" class="image-1 jive-image" height="274" src="https://community.esri.com/legacyfs/online/416753_map_properties01.png" width="633" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG __jive_id="416754" alt="" class="image-2 jive-image" height="339" src="https://community.esri.com/legacyfs/online/416754_map_properties02.png" width="617" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I don't share maps, but might have to&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2018 23:50:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56605#M2363</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-01T23:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: changing layer order in contents programmatically (i.e. using arcpy)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56606#M2364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you sir are an absolute GENIUS! Thank you! That worked perfectly!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Aug 2018 00:28:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56606#M2364</guid>
      <dc:creator>MarkJones7</dc:creator>
      <dc:date>2018-08-02T00:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: changing layer order in contents programmatically (i.e. using arcpy)</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56607#M2365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark... glad it worked out&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Aug 2018 17:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/changing-layer-order-in-contents-programmatically/m-p/56607#M2365</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-04T17:31:16Z</dc:date>
    </item>
  </channel>
</rss>

