Calling in 3D feature layers from Local Scene into a Jupyter Notebook for geoprocessing

671
3
Jump to solution
03-27-2023 05:48 AM
Labels (3)
DevRobinson
New Contributor III

Hello there,

I am asking if anyone knows the correct syntax for arcpy to call on and bring in any feature layer open in a local scene into a Jupyer notebook to run through a geoprocessing tool. I have dozens of layers open in the scene and need to use the Create3DObjectSceneLayerPackage tool, and I have the rest of the code to automate the process, but I need a way to grab them. And I need them all open in the scene and not stored in a geodatabase because they are 3D multipatches with vertical exaggeration and symbology that are not captured when they are not open in a scene. 

I cannot find anyone who knows the proper way to do this, but surely there must be a way!?

Would love an Esri rep's input especially! 

Thank you! 

0 Kudos
1 Solution

Accepted Solutions
ShaunWalbridge
Esri Regular Contributor

Yes, in the automation case you'll want to work with arcpy.mp to determine what layers you're using and passing to the downstream functions. Here's an example which shows some basic information about scene layers in the project:

project = arcpy.mp.ArcGISProject("CURRENT")
for project_map in project.listMaps():
    map_type = project_map.mapType
    print(f"Found {project_map.name} of type {map_type}")
    if map_type == 'SCENE':
        scene = project_map
        print(f"Working with scene {scene.name}")
        for layer in scene.listLayers():
            fl_str = 'is' if layer.isFeatureLayer else 'is not'
            print(f"  found {layer.name}, {fl_str} a feature layer")


Once you've used code like that to identify the layers you'd like to work with, you can then feed them into the GP tools you'd like to call.

Cheers, Shaun 

View solution in original post

3 Replies
ShaunWalbridge
Esri Regular Contributor

If you've already run the package tool once, you can visit the history pane of the application, and select "Copy Python command" as described in the Geoprocessing history documentation. That will give you a code snippet that you should be able to paste into your existing Notebook. If you're using Pro 3.1, you can also open your notebook directly in Pro, and drag and drop the layer names into cells, and that will similarly work against the active map.

If you need to work with the scenes from a standalone Notebook or in a context where Pro isn't directly involved, you'd want to start with arcpy.mp to first load the project, find your local scene, then work against the layers present in that scene, once you have the layer paths, you can use them as geoprocessing inputs as normal.

Cheers, Shaun

DevRobinson
New Contributor III

Hi Shaun,

I do really like the new drag and drop code history in 3.1, it's been a big help. 

And I have been using my Notebook in ArcPro with a Local scene open and manually inputting each layer from my scene into my code to run. This works fine, but I have DOZENS of layers to run through a single geoprocessing tool, is there a way to have it *automatically* call in each layer from the Scene, like you would for calling in everything from a geodatabase? 

My issue is automation, I just want the layers open in the scene.

Thanks!

0 Kudos
ShaunWalbridge
Esri Regular Contributor

Yes, in the automation case you'll want to work with arcpy.mp to determine what layers you're using and passing to the downstream functions. Here's an example which shows some basic information about scene layers in the project:

project = arcpy.mp.ArcGISProject("CURRENT")
for project_map in project.listMaps():
    map_type = project_map.mapType
    print(f"Found {project_map.name} of type {map_type}")
    if map_type == 'SCENE':
        scene = project_map
        print(f"Working with scene {scene.name}")
        for layer in scene.listLayers():
            fl_str = 'is' if layer.isFeatureLayer else 'is not'
            print(f"  found {layer.name}, {fl_str} a feature layer")


Once you've used code like that to identify the layers you'd like to work with, you can then feed them into the GP tools you'd like to call.

Cheers, Shaun