Hi,Thank you, I now understand why I cannot see both the entries for each TOID with a join. I think I have the answer to your question: the summary cannot work with the null values as null is not automatically assumed to be 0 in a numeric field? - Therefore it would be looking for the min or the max of nothing?Thanks again,Liam.
You really only need the Max of FromTo and ToFrom, since you don't care about the Null if a non-Null value exists. The only time you might care about a Min and Max is if you somehow had two different non-Null values for a single direction, which as I understand it, makes no sense for your model.
Dim CarOrientation Dim RoadOrientation RoadOrientation = [CarData_RoadLinks_Statistics.Orientation] Dim RoadCompass RoadCompass = [CarData_RoadLinks_Statistics.CompassA] Dim RoadCompassMax RoadCompassMax = RoadCompass + 170 If RoadCompassMax > 360 Then RoadCompassMax = RoadCompassMax - 360 ElseIf RoadCompassMax < 0 Then RoadCompassMax = RoadCompassMax + 360 End If Dim RoadCompassMin RoadCompassMin = RoadCompass - 170 If RoadCompassMin > 360 Then RoadCompassMin = RoadCompassMin - 360 ElseIf RoadCompassMax < 0 Then RoadCompassMin = RoadCompassMin + 360 End If Dim PointBearing PointBearing = [CarData_RoadLinks_Statistics.Bearing] If PointBearing > RoadCompassMin And PointBearing < RoadCompassMax Then CarOrientation = RoadOrientation End if If PointBearing < RoadCompassMin Or PointBearing > RoadCompassMax Then If RoadOrientation = "-" Then CarOrientation = "+" End if If RoadOrientation = "+" Then CarOrientation = "-" End if End if
I've had a look around on the web and I'm sure that the problem is to do with joining an ordinary table to a feature class, but I still have had no luck finding a solution.Has anyone come across this problem before and found a way around it?Thanks,Liam.
The calculation: [RoadLinks.FromTo] = [Stats.FromTo] [RoadLinks.ToFrom] = [Stats.ToFrom] Sample Data: _____________________________________________________________________________ | RoadLinks | Stats | |_____________________________________________________________________________| |TOID FromTo ToFrom | FromTo ToFrom | |_____________________________________________________________________________| |1 null null | 10 null | |2 null null | null 10 | |3 null null | null 5 | |4 null null | null 6 | |5 null null | 3 null | | | |
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # testVBScriptCodeBlock.py # Created on: 2013-10-05 12:40:22.00000 # (generated by ArcGIS/ModelBuilder) # Description: # --------------------------------------------------------------------------- # Import arcpy module import arcpy # Local variables: OrientationOfCar = "C:\\Documents and Settings\\rfairhur\\My Documents\\ArcGIS\\Default.gdb\\OrientationOfCar" JOIN_CarData_RoadLinks = "C:\\Documents and Settings\\rfairhur\\My Documents\\ArcGIS\\Default.gdb\\JOIN_CarData_RoadLinks" OrientationOfCar_View = "OrientationOfCar_View" OrientationOfCar_View__3_ = "OrientationOfCar_View" # Process: Make Table View arcpy.MakeTableView_management(OrientationOfCar, OrientationOfCar_View, "", "", "OBJECTID OBJECTID VISIBLE NONE;OrientationOfCar OrientationOfCar VISIBLE NONE;ID ID VISIBLE NONE") # Process: Add Join arcpy.AddJoin_management(OrientationOfCar_View, "ID", JOIN_CarData_RoadLinks, "ID", "KEEP_ALL") # Process: Calculate Field arcpy.CalculateField_management(OrientationOfCar_View__3_, "OrientationOfCar.OrientationOfCar", "CarOrientation", "VB", "Dim CarOrientation\\n\\nDim RoadOrientation\\nRoadOrientation = [JOIN_CarData_RoadLinks.Orientation]\\n\\nDim RoadCompass\\nRoadCompass = [JOIN_CarData_RoadLinks.CompassA]\\n\\nDim RoadCompassMax\\nRoadCompassMax = RoadCompass + 170\\n\\n If RoadCompassMax > 360 Then\\n RoadCompassMax = RoadCompassMax - 360\\n ElseIf RoadCompassMax < 0 Then\\n RoadCompassMax = RoadCompassMax + 360\\n End If\\n\\nDim RoadCompassMin \\nRoadCompassMin = RoadCompass - 170\\n\\n If RoadCompassMin > 360 Then\\n RoadCompassMin = RoadCompassMin - 360\\n ElseIf RoadCompassMax < 0 Then\\n RoadCompassMin = RoadCompassMin + 360\\n End If\\n\\nDim PointBearing\\nPointBearing = [JOIN_CarData_RoadLinks.Bearing]\\n\\nIf PointBearing > RoadCompassMin And PointBearing < RoadCompassMax Then\\n CarOrientation = RoadOrientation\\nEnd if\\n\\nIf PointBearing < RoadCompassMin Or PointBearing > RoadCompassMax Then\\n If RoadOrientation = \"-\" Then\\n CarOrientation = \"+\"\\n End if\\n\\n If RoadOrientation = \"+\" Then\\n CarOrientation = \"-\"\\n End if\\nEnd if ")
Hi,I managed to solve the problem: -I checked for null values throughout the database but the database had none. I then decided to export the table with the join to the same gdb, just called it: 'JOIN2_CarData_RoadLinks'. This made the join 'permanent', my code then whizzed through and completed successfully.It would appear that you cannot perform comparative VBScripts using the field calculator on a joined table. Or at least my installation won't 🙂Thanks again for your help, another 'bug' to add to the 'book of workarounds' 😉Liam.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.