<?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 Way to publish by addition to AGOL, an alternative to overwrite? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/way-to-publish-by-addition-to-agol-an-alternative/m-p/779869#M1139</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline; "&gt;Question&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Is it possible to script adding a new layer from an ArcGIS Pro project to a hosted feature service on AGOL, rather than overwriting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. desired scenario:&lt;/P&gt;&lt;P&gt;*I have an AGOL hosted feature service with a layer called: "2007"&lt;/P&gt;&lt;P&gt;*In ArcGIS Pro I have another layer "2008". I want to add this layer to the above service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, I am using the arcgis.gis module and the "publish" function to overwrite the whole hosted feature service, however, I am looking for&amp;nbsp;an alternative that is more efficient for large services.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Platform:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ArcGIS Pro 2.4&lt;/P&gt;&lt;P&gt;Python 3&lt;/P&gt;&lt;P&gt;Windows Server 2016&lt;/P&gt;&lt;P&gt;ArcGIS 10.8&lt;/P&gt;&lt;P&gt;AGOL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline; "&gt;Dead ends I explored:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1) "append"&lt;/P&gt;&lt;P&gt;documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/guide/appending-features/" rel="noreferrer nofollow" style="color: #172b4d; background-color: #ffffff;" target="_blank"&gt;https://developers.arcgis.com/python/guide/appending-features/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected:&lt;/P&gt;&lt;P&gt;The feature layer collection's append function is&amp;nbsp;for appending from a file geodatabase, or CSV or excel file. I am not seeing a good way to pull from the current Pro project's map itself. Also, it appears to append to an existing feature layer, not add a new layer to the data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) GeoAnalytics' append&lt;/P&gt;&lt;P&gt;documentation:&amp;nbsp;&lt;A href="https://enterprise.arcgis.com/en/portal/latest/use/geoanalytics-append-data.htm" rel="noreferrer nofollow" style="color: #172b4d; background-color: #ffffff;" target="_blank"&gt;https://enterprise.arcgis.com/en/portal/latest/use/geoanalytics-append-data.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected:&lt;/P&gt;&lt;P&gt;The GeoAnalytics append is for adding data to an existing layer, not a new layer to an existing dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) add_to_definition&lt;/P&gt;&lt;P&gt;documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html" rel="noreferrer nofollow" style="color: #172b4d; background-color: #ffffff;" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected: Incompatible json.&lt;/P&gt;&lt;P&gt;I used this in conjunction with FeaturesToJson to convert my Pro project's layer 2008 into json, but it doesn't appear to be compatible:&lt;/P&gt;&lt;P&gt;FeaturesToJson:&lt;/P&gt;&lt;P&gt;https://desktop.arcgis.com/en/arcmap/latest/tools/conversion-toolbox/features-to-json.htm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code I used:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;proj = arcpy.mp.ArcGISProject(projPath)&lt;/P&gt;&lt;P&gt;map = proj.listMaps()[0]&lt;/P&gt;&lt;P&gt;layer2008 = map.listLayers()[-2]&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;searchResultsFlc = gis.content.search("title:" + serviceName, item_type="Feature Layer Collection")&lt;BR /&gt;flcItem = searchResultsFlc[0]&lt;BR /&gt;flcol = arcgis.features.FeatureLayerCollection(flcItem.url, gis)&lt;/P&gt;&lt;P&gt;arcpy.conversion.FeaturesToJSON(layer2008, "layer2008.json")&lt;BR /&gt;&amp;lt;Result 'layer2008.json'&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flcol.manager.add_to_definition("layer2008.json")&lt;BR /&gt;Unable to add feature service definition.&lt;BR /&gt;Invalid definition for ESRI.ArcGIS.SDS.Metadata.FeatureServiceDescriptor&lt;BR /&gt;"layer2008.json"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4)&amp;nbsp;addDefinition, web api:&lt;BR /&gt;documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/add-to-definition-feature-service-.htm"&gt;https://developers.arcgis.com/rest/services-reference/add-to-definition-feature-service-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected: incompatible json&lt;/P&gt;&lt;P&gt;The json generated by FeaturesToJSON is incompatible with the sample json posted in the documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Pete&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Aug 2020 20:19:08 GMT</pubDate>
    <dc:creator>PeterLee3</dc:creator>
    <dc:date>2020-08-18T20:19:08Z</dc:date>
    <item>
      <title>Way to publish by addition to AGOL, an alternative to overwrite?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/way-to-publish-by-addition-to-agol-an-alternative/m-p/779869#M1139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline; "&gt;Question&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Is it possible to script adding a new layer from an ArcGIS Pro project to a hosted feature service on AGOL, rather than overwriting?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. desired scenario:&lt;/P&gt;&lt;P&gt;*I have an AGOL hosted feature service with a layer called: "2007"&lt;/P&gt;&lt;P&gt;*In ArcGIS Pro I have another layer "2008". I want to add this layer to the above service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently, I am using the arcgis.gis module and the "publish" function to overwrite the whole hosted feature service, however, I am looking for&amp;nbsp;an alternative that is more efficient for large services.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Platform:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ArcGIS Pro 2.4&lt;/P&gt;&lt;P&gt;Python 3&lt;/P&gt;&lt;P&gt;Windows Server 2016&lt;/P&gt;&lt;P&gt;ArcGIS 10.8&lt;/P&gt;&lt;P&gt;AGOL&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: underline; "&gt;Dead ends I explored:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;1) "append"&lt;/P&gt;&lt;P&gt;documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/guide/appending-features/" rel="noreferrer nofollow" style="color: #172b4d; background-color: #ffffff;" target="_blank"&gt;https://developers.arcgis.com/python/guide/appending-features/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected:&lt;/P&gt;&lt;P&gt;The feature layer collection's append function is&amp;nbsp;for appending from a file geodatabase, or CSV or excel file. I am not seeing a good way to pull from the current Pro project's map itself. Also, it appears to append to an existing feature layer, not add a new layer to the data set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) GeoAnalytics' append&lt;/P&gt;&lt;P&gt;documentation:&amp;nbsp;&lt;A href="https://enterprise.arcgis.com/en/portal/latest/use/geoanalytics-append-data.htm" rel="noreferrer nofollow" style="color: #172b4d; background-color: #ffffff;" target="_blank"&gt;https://enterprise.arcgis.com/en/portal/latest/use/geoanalytics-append-data.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected:&lt;/P&gt;&lt;P&gt;The GeoAnalytics append is for adding data to an existing layer, not a new layer to an existing dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3) add_to_definition&lt;/P&gt;&lt;P&gt;documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html" rel="noreferrer nofollow" style="color: #172b4d; background-color: #ffffff;" target="_blank"&gt;https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected: Incompatible json.&lt;/P&gt;&lt;P&gt;I used this in conjunction with FeaturesToJson to convert my Pro project's layer 2008 into json, but it doesn't appear to be compatible:&lt;/P&gt;&lt;P&gt;FeaturesToJson:&lt;/P&gt;&lt;P&gt;https://desktop.arcgis.com/en/arcmap/latest/tools/conversion-toolbox/features-to-json.htm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample code I used:&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;proj = arcpy.mp.ArcGISProject(projPath)&lt;/P&gt;&lt;P&gt;map = proj.listMaps()[0]&lt;/P&gt;&lt;P&gt;layer2008 = map.listLayers()[-2]&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;searchResultsFlc = gis.content.search("title:" + serviceName, item_type="Feature Layer Collection")&lt;BR /&gt;flcItem = searchResultsFlc[0]&lt;BR /&gt;flcol = arcgis.features.FeatureLayerCollection(flcItem.url, gis)&lt;/P&gt;&lt;P&gt;arcpy.conversion.FeaturesToJSON(layer2008, "layer2008.json")&lt;BR /&gt;&amp;lt;Result 'layer2008.json'&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flcol.manager.add_to_definition("layer2008.json")&lt;BR /&gt;Unable to add feature service definition.&lt;BR /&gt;Invalid definition for ESRI.ArcGIS.SDS.Metadata.FeatureServiceDescriptor&lt;BR /&gt;"layer2008.json"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4)&amp;nbsp;addDefinition, web api:&lt;BR /&gt;documentation:&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/add-to-definition-feature-service-.htm"&gt;https://developers.arcgis.com/rest/services-reference/add-to-definition-feature-service-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Reason rejected: incompatible json&lt;/P&gt;&lt;P&gt;The json generated by FeaturesToJSON is incompatible with the sample json posted in the documentation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Pete&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2020 20:19:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/way-to-publish-by-addition-to-agol-an-alternative/m-p/779869#M1139</guid>
      <dc:creator>PeterLee3</dc:creator>
      <dc:date>2020-08-18T20:19:08Z</dc:date>
    </item>
  </channel>
</rss>

