ArcGIS Pro removing map layers when data is overwritten or deleted

1039
4
Jump to solution
02-13-2023 09:09 AM
Labels (2)
AaronCole1
Occasional Contributor

I'm running a very simple process in a Jupyter Notebook that overwrites data in a few layers that are symbolized in a map series and I just noticed that during the geoprocessing ArcGIS Pro is now removing the layers from my map and layout.

0 Kudos
1 Solution

Accepted Solutions
AaronCole1
Occasional Contributor

Having a conversation with myself...but there is a setting in the Pro GP options that accomplishes this...thank goodness. Remove layers that reference data overwritten by geoprocessing tools

View solution in original post

0 Kudos
4 Replies
AaronCole1
Occasional Contributor

So this isn't entirely true...the Python window USED to not do this, but now it does. What am I missing? I'm overwriting features via Python but that shouldn't cause me to lose the layer. It resets all symbology, labeling, map series settings, and legend settings, even if I close the Layout or Map.

Look at the attached gif. The Conflict Property Layer is sourced to the COI_Parcels dataset, when I run the Python script, that layer gets overwritten with updated information, a normal ETL routine, simple as can be. However, Pro is removing the layer, what the heck?

0 Kudos
DanPatterson
MVP Esteemed Contributor

you can check or set environment settings, like adding results to display.  This used to be only set at the application level, but you can set it as an environment setting beginning in python 2.9.  If the layer is being removed (which it normally does), you can add the final result back in (in theory) by setting

addOutputsToMap   (Read and Write)

in

env—ArcGIS Pro | Documentation

 


... sort of retired...
0 Kudos
AaronCole1
Occasional Contributor

Hi Dan,

Thanks for responding. The issue I'm having is with the layers getting removed when their data sources are overwritten, not with the layers getting added in afterwards.  I think ESRI is trying to keep house, so that when data is deleted it's removed from any maps, but in this context that's cartographic suicide.  I'm overwriting the layer's data source, something I've been doing as a typical workflow for many years from the Python window, but now I'm seeing that when I overwrite a dataset, the layer is removed from the map, which causes a loss of all layer-related settings including symbology, labeling, participation in a legend or map series.  I can't remember when I first noticed it but it makes the Python window and Jupyter Notebook rather useless to me for many workflows. I'm surprised more users aren't barking about this issue. I can just do my work in PyCharm or wherever else, but for hybrid workflows where you want to visually inspect results midstream, I love using the Python window or more recently a Notebook.  Sad trombone. 

I attached a gif of the same workflow in ArcMap, data gets overwritten, layers become unavailable but never removed, then once the data is back the layers are refreshed.

0 Kudos
AaronCole1
Occasional Contributor

Having a conversation with myself...but there is a setting in the Pro GP options that accomplishes this...thank goodness. Remove layers that reference data overwritten by geoprocessing tools

0 Kudos