Automated Rebuilding of Network Datasets - Oracle 11g SDE

1003
5
Jump to solution
12-02-2017 01:17 PM
DuncanFetner1
New Contributor II

I'm working on some Python scripts to automate the rebuilding of a couple of different network datasets based on new data coming in from our SDE. To ensure I wouldn't experience any SDE related issues (not really a database guy), I set up the network datasets in a FGDB. However, I'm experiencing some performance issues have decided to try to move the NDs to a feature dataset in SDE. This is where my issues have started coming up.

Since creating NDs isn't possible via ArcPy without getting into areas waaaay outside my skill level, I've got my scripts creating new edge and junction feature classes in memory, removing all rows in the participating ND feature classes, inserting the new features from memory into the empty participating feature classes, and rebuilding the existing ND. I created a new ND in our SDE, and attempted to run my first test, but hit issues when I began my update cursor to delete the participating features. Got the ol Workspace is Already in Transaction Mode error. I tried to register the feature dataset as versioned to see if that would help things, but since SDE NDs don't allow for versioning of feature classes that already participate in NDs, I couldn't. I'm at a loss here. Here's a code sample (sorry that it's an image, can't get code formatted to look right otherwise):

existingJunctions = r"pathtoSDEFeatureDataset\Junctions"
existingEdges = r"pathtoSDEFeatureDataset\Edges"
networkDataset = r"pathtoSDEFeatureDataset\NetworkDataset_ND"

edit = arcpy.da.Editor(r"path to SDE Database")
#tried all parameter combinations before settling on False False
edit.startEditing(False, False)

#delete all rows from existing ND junctions
with arcpy.da.UpdateCursor(existingJunctions, "*") as uCur:
for row in uCur:
uCur.deleteRow()

#insert updated junctions from memory into participating junctions fc
with arcpy.da.SearchCursor(junctions, "*") as sCur:
with arcpy.da.InsertCursor(existingJunctions, "*") as iCur:
for row in sCur:
iCur.insertRow(row)

#delete all rows from existing ND edges
with arcpy.da.UpdateCursor(existingEdges, "*") as uCur:
for row in uCur:
uCur.deleteRow()

#insert updated edges from memory into participating edges fc
edgeFields = [f.name for f in arcpy.ListFields(existingEdges) if f.name != "SHAPE_Length"]
edgeFields.insert(0, "SHAPE@")
with arcpy.da.SearchCursor(fiber, fiberFields) as sCur:
with arcpy.da.InsertCursor(existingFiber, fiberFields) as iCur:
for row in sCur:
iCur.insertRow(row)

#end edit session
edit.stopEditing(True)

If there is a suggestion on how to get this code working OR another idea on how to handle regular updates of network datasets without manual creation of new NDs, please let me know. Any help is tremendously appreciated!!

0 Kudos
1 Solution

Accepted Solutions
MelindaMorang
Esri Regular Contributor

If you use ArcGIS Pro, you can automatically re-create the network dataset from a template using the Create Template From Network Dataset and Create Network Dataset From Template tools.

View solution in original post

5 Replies
MelindaMorang
Esri Regular Contributor

If you use ArcGIS Pro, you can automatically re-create the network dataset from a template using the Create Template From Network Dataset and Create Network Dataset From Template tools.

DuncanFetner1
New Contributor II

Unfortunately, we're running 10.4.1, so that option isn't available. Good suggestion though! Hoping to get my hands on Pro sometime soon to play around with. However, if I was able to create a ND XML template via Pro through some other avenue, is there a "scenic route" I could possibly take to utilize that XML in 10.4?

0 Kudos
DuncanFetner1
New Contributor II

Resurrecting this one: we just started using Pro within the last couple of weeks and I have successfully been able to utilize ND templates. Truly a lifesaver. Thank you!

0 Kudos
JaySandhu
Esri Regular Contributor

Hopefully you can use Melinda's suggestion to using the GP tool. 

But I want to clarify one thing. You say:

" I tried to register the feature dataset as versioned to see if that would help things, but since SDE NDs don't allow for versioning of feature classes that already participate in NDs, I couldn't. I'm at a loss here."

A feature dataset containing a network dataset CAN be versioned. And then the feature classes that are taking part in a network dataset can be edited.

Jay Sandhu

0 Kudos
DuncanFetner1
New Contributor II

Thanks for the reply Jay. Unfortunately our organization isn't using Pro, so that door is mostly closed. I forgot to edit my post, but I did learn that versioning was possible (in fact, I had already registered the participating fcs as versioned before posting) but I still didn't have any success. The source for my edge features is too large for my poor little computer to handle and though I didn't realize it at the time, I was running out of memory mid-build. I have another workaround I'm experimenting with, so hopefully it will take care of it.

0 Kudos