Select to view content in your preferred language

Shapefile added using addDataFromPath does not show on map

596
2
05-23-2023 01:08 PM
Labels (2)
KarolDuarte
New Contributor II

Hello everyone,

I'm facing an issue regarding the addDataFromPath method.

I have used it successfully when I was working with a notebook inside my project to add some shapefiles to a map. However, now I need to convert the notebook into a python script and it is not working. When I run the script I get no errors at all but the shapefiles won't show up on the selected map.

Here's how my code looks like:

project = <project_path>
 
aprx = arcpy.mp.ArcGISProject(project)
map = aprx.listMaps(map_name) [0]
 
shape = os.path.join(out_path, out_name_pto)
map.addDataFromPath(shape)
I have also tried the arcpy.MakeFeatureLayer_management function, but it still did not work.
I have been working with the project opened, but I need a way to may the shapefiles to be added whether to the current project or to another project. I have been using the project path, rather than 'CURRENT' for adding the shapefiles.
 
0 Kudos
2 Replies
DavidPike
MVP Frequent Contributor
aprx.save()
KarolDuarte
New Contributor II

Thanks!
In the end, I had removed this part entirely from the code, because I needed it ASAP, but I will give it a new try!

0 Kudos