Friday 17 May 2019

arcgis desktop - Automate Naming of Stormwater Network (Geometric network)


We have a geometric network representing our stormwater network. For anyone unfamiliar with stormwater drainage networks, they are composed of pipes and pits (simplified for this question). Pits are required wherever two pipes join or a change of direction is required. So in the geometric network, pits are junctions and pipes are edges.


The feature classes within the geometric network are a Point Feature for the pits and a polyline Feature for the pipes.


My task is attribute every pipe and pit with unique name in line with our Naming Policy. The name of the pipe or pit is dependent on its location within the network. Simplified naming policy is as follows:


Pits are given a number starting with 1 at the outlet (furthest downstream) Pipes are given the number of their upstream pit


I would like to automatic this naming process. I have little experience in arcgis and python, but i have a background in Java. Does anyone have any advice as to how to achieve this? Manually naming the pits/pipes will take 4-8 weeks. I would rather spend 8 weeks learning ArcObjects etc. I’m guessing i need to represent the network as a graph in java, from there the naming process would be easy.



How do I extract the geometric network relationships into a graph?



Answer



It could just be my perspective as an ArcGIS jockey, but handling the feature relationships in your own code sounds harder. If you take advantage of ArcGIS's ability to do that, I think it's simpler. How do you feel about spending some of your 8 weeks learning ArcGIS and Python? :) I don't know if there is a better way to traverse a network, but you can at least crawl your way up by repeatedly using "select by location" in ArcMap. You presumably could do the same in ArcObjects. But if I were doing this, I would write a python script that cycles through using select by location. We will assume that the user will select pit #1 interactively, store its name in the attribute table, and then kick off the script. Script logic looks like this:




  1. Use arcpy.MakeFeatureLayer_management to make a feature layer of all the pipes, and another feature layer of all the pits. I'll call those AllPipes and AllPits




  2. Use arcpy.MakeFeatureLayer_management with a SQL query to make a feature layer that contains (only) pit #1, named OnePit.





  3. arcpy.SelectLayerByLocation_management with the intersect operation will select the features in AllPipes that touch OnePit. Then use an edit cursor to go through those and apply whatever the business rules are for assigning names for them based on what you will name their upstream pits in the next step. Write the name into the pipe feature inside the cursor loop using the setValue method for the row object.




  4. Then for each pipe that you have selected, use arcpy.SelectLayerByLocation_management again to select everything in AllPits that intersects that pipe. (It may be necessary to make a feature layer out of each pipe using a SQL query that selects it based on its name.) This will get you two pits (upstream and down), but one of them already has a name. Assign the name to the one that doesn't have one.




  5. Now you have one or more pipe/pit pairs that you've named. Make OnePit again, using each of the pits you just gave names to in turn, lather, rinse, repeat.





One drawback of this is that for a giant network, doing select by location iteratively like that is going to be slow. Using an in-memory workspace would help a lot with that.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...