Select to view content in your preferred language

Plotting shapefiles from gdb to an aprx file

190
2
Jump to solution
3 weeks ago
HusamOqer
New Contributor II

Hello

 

I am working on a script and I am stuck at the stage of plotting the shapefiles from gdb's to an existing 2 different aprx files.

I need to run the code from Pyscripter not from the ArcGIS Pro directly as there will be 2 aprx files.

Thanks! 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
BBowers_napacounty
New Contributor II

I didn't test this, but this is the general idea:

shapefile_path = r"C:\PATH\Shapefile.shp"
aprx_list = [r"C:\PATH\First.aprx", r"C:\PATH\Second.aprx"]
import arcpy
for aprx_path in aprx_list:
    p = arcpy.mp.ArcGISProject(aprx_path)
    m = p.listMaps()[0]  # assumes data to be added to first map listed
    m.addDataFromPath(shapefile_path)‍‍‍‍‍
    p.save()

View solution in original post

2 Replies
BBowers_napacounty
New Contributor II

I didn't test this, but this is the general idea:

shapefile_path = r"C:\PATH\Shapefile.shp"
aprx_list = [r"C:\PATH\First.aprx", r"C:\PATH\Second.aprx"]
import arcpy
for aprx_path in aprx_list:
    p = arcpy.mp.ArcGISProject(aprx_path)
    m = p.listMaps()[0]  # assumes data to be added to first map listed
    m.addDataFromPath(shapefile_path)‍‍‍‍‍
    p.save()
HusamOqer
New Contributor II

Thank you so much I just tried it and it worked! 

0 Kudos