This past week, I was having a moment dealing with Network Analyst. I need to use this tool for my dissertation research, and for some odd reason, I thought it was going to be a piece of cake getting this part done. Oh how I was wrong. I felt like Rocky in Rocky III when he underestimated Clubber Lang and got knocked out.
I used the OD Cost Matrix in order to find the least cost paths from my origins(population centroids derived from census tracts) to destinations(OBGYN providers) and vice-versa. When I first ran the analysis, it could only find 50% of the locations. However, I buckled down, kept my eye on the tiger, and as of yesterday, all of the locations have been found.
Here’s the process that I went through in order to fix this network. If you are having problems with the OD Cost Matrix not locating points, ask yourself these questions. And while you’re doing this, I recommend binging a show or set of movies that you like because the process is painful. In my case, it was Rocky I-V. Which is why you see all the Rocky GIFS in this post.
If you didn’t, I highly recommend it. Go ahead and export those problem points into a separate shapefile. What I did to create this “ProblemPoints” shapefile was copy the error message after the OD Cost Matrix Analysis, put it in an Excel sheet, changed it from Text to Columns(you can find this under the Data tab) in which I isolated the names of the problem points and replaced the quotes from double to single(not sure if I needed to do this but oh well). Then, I added commas using the formula that you see on the Excel sheet. I did this so I can easily select them because seriously, do you want to write each location name out when you make the select by attributes query? I don’t think so.
After you are finished messing around in Excel, then go back to ArcMap, open your attribute table, and do a Select by Attributes query. In the query box, something to the effect of “Name” IN (‘Location 1’, ‘Location 2’, ‘Location 3’).
Of course modify this based on your own data. After you run the query, go into your Table of Contents, Right-click on the shapefile you did the query on and Export the data.
After you export your problem points, go ahead and run a Service Area analysis to see where your lines break. Click on the Network Analyst button and click on New Service Area in the drop down menu. If you haven’t done it already, Click on the Network Analyst window button on the right of the Network Analyst button(it’s an icon with a table and little flag).
Now you need to change some settings. If you have your Network Analyst Window open, Make sure your Service Area analysis is the one on display and click on the settings button on the right of the Network Analyst Window. Now it’s time to change some things. Click on the Line Generation tab and click on Generate Lines .
Click on the Polygon Generation tab and uncheck Generate Polygons.
Click on the Network Locations tab and under Finding Network Locations, set that Search Tolerance up to an obscene distance.
Once you make those changes, press OK and press the Solve button on the Network Analyst toolbar to solve your Service Area analysis.
Brace yourself, this is going to be a long process. After you run the service area analysis, notice where the lines break. Like really notice where they break. Zoom on in. If you don’t see roads connecting where they should, you’re going to have to do something about it. What I did was to make a topology rule and check my shapefile against that rule. For me, the lines were indeed not connecting where they should. What I did to do this was to create a File Geodatadase and then a Feature Dataset within my geodatabase. I named it “TopologyCheck” to keep the name simple. Import your shapefile within the Feature Dataset. Now it’s time to set some rules to get your shapefile in order. Right-click on your feature dataset, click on New and Topology. Keep on going through the prompts and then make sure that you click on the Add Rule button on the Specify rules for the topology prompt. The rule I chose was Must Not Have Dangles. Press Next, check the last window to see if everything is right, and click Finish.
Now you need to see how much of a hot mess you are dealing with. Click on your topology, go to the Errors tab and click on the Generate Summary button to see how many errors you have. Take a breath, because it might be bad. But not as bad as you think. But still bad.
After you do that, make sure you add your topology to the Table of Contents. If you get a prompt asking to add all participating feature classes that participate in the topology to the map, press yes. Now you need to start editing your roads feature class. Go to Editor, Start Editing and choose our road shapefile/feature class that you wish to clean up.
If you look at your Table of Contents, you will see the symbology for the various types of errors that occur based on your topology rules:
Click on the Error Inspector button(little table with an x on it), click on Search Now and see what errors are present in your data. To make it more manageable, I would zoom to one error and then click on Visible Extent Only to see the errors within the extent that you currently see.
Now it’s time to fix those errors. You are going to need either snap the roads to connect to the other roads or you need to mark the error as an exception. You can do this by right-clicking on the feature in question in the Error Inspector. A lot of my errors were exceptions since the dangle was warranted (i.e. the end of the road). Like I said before, make sure you have something playing in the background because this is a tedious process. It took me a couple of days to fix my errors. I definitely was feeling like I was going under a Rocky IV training montage because it was mentally(and physically because I got headache while doing it) taxing.
Hearts on fire and all of that. Actually, I finished it all by the time I got to Rocky V(which is the worst movie out of the franchise by the way).
You’re going to have to re-calculate some geometries and add any additional data to any newly created lines you made during the topology check. For me, I needed to re-calculate the geometry and add speed limits to my newly created lines.
You absolutely have to do this if you want to see if your fixes did the trick. In order to bring some order to the chaos that can happen, I would recommend either creating a new workspace or putting your data in a new data frame. I exported the roads feature class I had in my TopologyCheck geodatabase and created a new network to just keep everything organized.
Once you load your locations in the OD Cost Matrix, you are going to have to recalculate the location fields since you are using an updated road network. You just need to right-click on your Origins and Destinations and click on Recalculate Location Fields.
Go ahead, do it. If you still have errors, then you’re going to have to do 2-7 again on the checklist.
Keep at it, and hopefully everything will be fixed(or a lot better than before). It took me at least three times to do so. I did tried to cut corners by only fixing the roads near the points which could not be found, but I ended up having to fix all of the errors in my roads shapefile. Sometimes you just have to go the distance to get everything to work! It sucks and is time-intensive, but you have to do what you have to do. It was definitely a learning experience for me so I hope you find this checklist useful when trying to troubleshoot with Network Analyst!