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 = # path to shape file
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0] # assumes data to be added to first map listed
map.addDataFromPath(shp_path)
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.