HOW TO
When working on a project in ArcGIS Pro, map frames and layouts can only be viewed by adding the project to ArcGIS Pro and and checking each layer one at a time. This can be time-consuming, Thus, automating the process using Python is an option.
The following script iterates over an ArcGIS project file (.aprx) and searches for vector tile layers.
import arcpy
aprx = arcpy.mp.ArcGISProject(r"C:\Users\Documents\ArcGIS\MyProject\MyProject.aprx")
m = aprx.listMaps("MAP")[0]
for lyr in m.listLayers():
desc = arcpy.da.Describe(lyr)
if desc.get('dataType') == 'VectorLayer':
print ("YES")
if desc.get('dataType') != 'VectorLayer':
print ("NO")
The following shows the full script:
import arcpy
aprx = arcpy.mp.ArcGISProject(r"C:\Users\Documents\ArcGIS\MyProject\MyProject.aprx")
m = aprx.listMaps("Map")[0]
for lyr in m.listLayers():
print (lyr)
desc = arcpy.da.Describe(lyr)
print (desc)
if desc.get('dataType') == 'VectorLayer':
print ("yes")
if desc.get('dataType') != 'VectorLayer':
print ("no")
print ()
Article ID: 000022752
Get help from ArcGIS experts
Start chatting now