Good afternoon.
I have a python script that I am using to obtain kml data and then turn that into a geodatabase, extract the information and create 3 shapefiles which I then need to publish as a web layer. I have the script so that it does not automatically add the created geodatabase or shapefile automatically as some cannot be published as feature layers. I am trying to get just the shapefiles to the map. The snippet I am using is this:
aprx = arcpy.mp.ArcGISProject("Current")
map = aprx.listMaps()[0]
map.addDataFromPath('C:/directory/filename.shp')
I found a post from bixb0012 which I also tried, from 2017, which is this:
shp_path <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> <SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"># path to shape file</SPAN>
aprx <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> arcpy<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>mp<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>ArcGISProject<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;">"CURRENT"</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
map <SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;">=</SPAN> aprx<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>listMaps<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">[</SPAN><SPAN class="" style="color: #990000; border: 0px; font-weight: inherit;">0</SPAN><SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">]</SPAN> <SPAN class="" style="color: slategray; border: 0px; font-weight: inherit;"># assumes data to be added to first map listed</SPAN>
map<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">.</SPAN>addDataFromPath<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">(</SPAN>shp_path<SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;">)</SPAN>
And it did not work either.
The error I receive on both is this:
Traceback (most recent call last) In [3]: Line 44: map.addDataFromPath('C:/GIS_Projects/VMRC_KMZ/VMRC_Oyster_Clam_Data/shp/VMRC_Public_Clamming_Grounds.shp') File c:\program files\arcgis\pro\Resources\arcpy\arcpy\_mp.py, in addDataFromPath: Line 1779: return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True))) RuntimeError: ---------------------------------------------------------------------------
I am using PRO version 2.6.1.
Thank you for any help / suggestions.