Select to view content in your preferred language

Need a script to replace data in a network dataset

12-15-2016 11:04 AM
New Contributor III

Hello - looking for help with a Python script - I have a feature class consumed in a network dataset (street centerlines). Once a month, we get new data, and I need to replace the old with the new.

What I want to this Python script to do:- Replace the old data with the new data, - Rebuild the network dataset and address locator.

Issues: - In a non-versioned dataset, the fc cannot be worked with the truncate tool, as the 'Operation not supported on a feature class in a controller dataset', aka, it is still part of the network dataset.

- In a versioned dataset, truncate is "not supported on a versioned table’.

In a versioned dataset, and in an edit session within ArcMap, truncate is also "not supported on a versioned table’.

Acknowledgements: - There is no way to remove the fc from the network dataset using Python, because of the inability to work with the feature class wizard. There is also no way to remove the fc from the dataset without removing it from the network dataset. Also, deleting the entire dataset and rebuilding it and the network dataset is not an option, for the same reason with Python/the wizard; (re)building the network dataset IS available to Python.


Current, manual workflow: 1. Remove the network dataset components, 2. Remove the old fc, 3. Import the new fc, 4. Rebuild the network dataset based on the new fc, and 5. Rebuild the address locator. This workflow is not repeatable through Python.

In another attempt to find a fix, was able to work through the entire process of 1. Registering the dataset as versioned, 2. Start an edit session in ArcMap, 3. Select and delete all assets in the fc, 4. Copy and paste (I know, not the proper method) the new data to the original fc (identical schema), 5. Rebuild the network dataset with the new data, and 6. Unregister the dataset. I'm not able, to put this into a Python script successfully using an existing map document, edit session, select, delete, add, etc. From start to finish, it's clunky and very time-consuming, dealing with 35k assets.

I wanted to use truncate and append, but that solution isn't looking like it will work for me. I want this 100% automated, no fingers to touch anything.

I've gone through 30 variations of scripts - good learning experience - however... any ideas? Working with SDE database connections and datasets. New data resides in a different db.

3 Replies
MVP Emeritus

FYI 10.5 offers nothing new in that regard 

What's new in ArcMap—ArcGIS Help | ArcGIS Desktop 

0 Kudos
MVP Notable Contributor

Don't know if this helps, but I have a somewhat similar situation.  I have Water/Sewer/Storm geometric networks, versioned datasets. I often times do something similar to your last attempt, but after selecting and deleting the assets, I then use the append command to put the updated assets back in there instead of copy/paste.  A lot faster than trying to copy/paste, not to mention that will normally crash/seize me up if there are many assets to transfer.

Not sure on your network dataset as my geonets have edges and junctions (lines and points).  I only delete/append the line data, and when I append it back in, it automatically rejoins all the network stuff so I don't have to re-build.

Like I said, different but "similar", if you haven't tried the delete/append method, you may give it a try.


0 Kudos
MVP Emeritus

I do something similar to what Rhett Zufelt‌ suggests with the append tool.  Because my network is in GCS and my source data ( vesioned) is in state plane with a different schema, my work flow goes something like this;

One way replicate from source enterprise gdb to file gdb

Use delete features tool on the GCS data followed by the append tool with the no test option that allows me to map attributes from my child replica source data to the GCS feature class

Recreate the network manually.

I'm not aware of a tool or python function that creates a network.  Maybe jsandhu-esristaff can provide some insight for us.

That should just about do it....
0 Kudos