Select to view content in your preferred language

How to update the data source for Network Analyst Layer by arcpy

196
0
01-19-2025 09:58 PM
LeoDeng
Frequent Contributor

Hi All,

    I‘m using the script to update layer data source in a project file (*.aprx).  However , there is no connectionProperties for NetworkAnalystLayer.

   

 

def _update_layer_data_source(layer, database, dataset):
    try:
        if layer.isNetworkAnalystLayer:
            # The attribute 'connectionProperties' is not supported on this instance of Layer.
            pass
        else:
            layer_connection_properties = layer.connectionProperties
            layer_connection_properties['connection_info']['database'] = database
            layer_connection_properties['dataset'] = dataset
            layer.updateConnectionProperties(layer.connectionProperties, layer_connection_properties)
    except Exception as ex:
        pass

 

 
Thanks,
Leo

Tags (1)
0 Kudos
0 Replies