POST
|
I would expect to see small numbers in the distance calculations. Looking at the street data that I used to create my network, 99.8% of the distances are less than a mile. I would try a simple route calculation and see if the results make sense. My data is also projected in UTM.
... View more
11-12-2013
06:56 AM
|
0
|
0
|
770
|
POST
|
To determine the values for your distance field, create a new field in the attribute table of your streets feature with a field type of double. Right click on the newly created field heading an select "Calculate Geometry". For the "Units", select "Miles" from the dropdown menu. This will calculate the disatance in miles for every street segment within your street feature. You then can do your time calculation based off of this field. You can also use this field for the distance attribute when you create you network.
... View more
11-12-2013
06:20 AM
|
0
|
0
|
770
|
POST
|
Hi, I am trying to display results that did not match from geocoding that displays Member IDs in a tkMessageBox. The code below seems to work (the last print statement shows the expected IDs), but the tkMessageBox only displays the last value in the valueList. Any advice on how to display all of the values in the valueList in the tkMessageBox would be greatly appreciated. Thanks, B import arcpy, tkMessageBox input_MEM = r"C:\test.gdb\Members" field = "MEM_ID" valueList = [] rows = arcpy.SearchCursor(input_MEM,"\"Loc_name\" IS NULL","",field,"") for row in rows: value = row.getValue(field) if value not in valueSet: valueList.append(value) for ID in valueList: print ID tkMessageBox.showinfo("Process Completed","Member(s) " + str(ID) + " could not be located.")
... View more
09-27-2013
09:14 AM
|
0
|
2
|
674
|
POST
|
Here is what I do. class LicenseError(Exception):
pass
import arcpy, os, traceback, sys, tkMessageBox
from arcpy import env
arcpy.env.overwriteOutput = True
#Checkout Network Analyst License
try:
if arcpy.CheckExtension("Network") == "Available":
arcpy.CheckOutExtension("Network")
else:
# Raise a custom exception
#
raise LicenseError
#Set Variables
Members = r"C:\ArcGIS\HSD\HSD_May2013\HSD.gdb\Members"
Shell_D = r"C:\ArcGIS\HSD\HSD_May2013\HSD.gdb\Shell_D"
Distance = r"C:\ArcGIS\HSD\HSD_May2013\HSD.gdb\Distance"
ND = r"C:\ArcGIS\Geodabases\Basemap.gdb\na\na_ND"
OD_Lines = r"in_memory\OD_Lines"
Lines = r"OD_Matrix\Lines"
OD_Matrix = "OD_Matrix"
#Processes for Distance Analysis
arcpy.MakeODCostMatrixLayer_na(ND,OD_Matrix,"Distance","","1")
arcpy.AddLocations_na(OD_Matrix, "Origins", Members, "", "", "", "", "", "Clear")
env.workspace = r"C:\ArcGIS\HSD\HSD_May2013\Database"
workspaces = arcpy.ListWorkspaces("Distance*", "FileGDB")
for workspace in workspaces:
expression1 = workspace[-6:-4]
print "Distance: " + expression1 + " Miles"
env.workspace = workspace
fclist = arcpy.ListFeatureClasses()
for fc in fclist:
expression2 = '"' + str(fc[4:8]) + '"'
arcpy.CalculateField_management(Shell_D, "SpecialtyCode", expression2, "PYTHON_9.3")
print "Calculating Distance for Specialty Code " + expression2
arcpy.AddLocations_na(OD_Matrix, "Destinations", fc, "Name Code #", "", "", "", "", "Clear")
arcpy.Solve_na(OD_Matrix, "SKIP","CONTINUE")
arcpy.Select_analysis(Lines, OD_Lines, "\"Total_Distance\" <=" + expression1)
count = arcpy.GetCount_management(OD_Lines)
arcpy.CalculateField_management(Shell_D, "Distance", count, "PYTHON_9.3")
arcpy.Append_management (Shell_D, Distance)
except:
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
tkMessageBox.showwarning("Error",pymsg)
finally:
# Check in the Network Analyst extension
arcpy.CheckInExtension("Network") If I remember correctly, I had to make the output of the OD Matrix an in memory table(using the arcpy.Select_analysis) and append it to an empty table. I think I kept getting an error if I tried writing the table straight to disk. The code above is in a standalone script.
... View more
06-13-2013
08:52 AM
|
0
|
0
|
374
|
POST
|
If you are trying to get the lines object from an od cost matrix, you will need to use the "Select" tool. It would look something like this (sorry it's a dirty example): ND = "your network dataset"
OD_Lines = "output location for table
Lines = r"OD_Matrix\Lines"
OD_Matrix = "OD_Matrix"
arcpy.MakeODCostMatrixLayer_na(ND,OD_Matrix,"Distance","","1")
arcpy.AddLocations_na(OD_Matrix, "Origins", "your input")
arcpy.AddLocations_na(OD_Matrix, "Destinations", "your input")
arcpy.Solve_na(OD_Matrix, "SKIP","CONTINUE")
arcpy.Select_analysis(Lines, OD_Lines)
... View more
06-05-2013
02:58 PM
|
0
|
0
|
639
|
POST
|
With a route layer, you can load multiple features into it to be able to solve the route. If you define the RouteName field in the route layer (in your case you could use the Hospital ID), you can solve routes between Members and the Hospital they were seen at. The only downside to this is getting the data set up correctly. You will need 2 features to do this, a Member feature and a Hospital feature. Here's the catch, in the hospital feature, there needs to be a record for every Member. So, if you have 20 Members total, 10 are seen at Hospital a, and 10 were seen at Hospital b, the Hospital feature will need 20 record total (10 Hospital a and 10 Hospital b). You can then load each feature into the stops of the Route Layer with the RouteName field defined on Hospital ID and it will calculate the distance between each Member and the Hospital they were seen at. There are quite a few threads in the Network Analysis forums about how to use the RouteName field. I hope this makes sense and helps out.
... View more
05-30-2013
07:16 AM
|
0
|
0
|
379
|
POST
|
Look into using a Route layer instead of an OD Cost Matrix. You can you the ROUTENAME field in the Route layer to link the stops (orgins and destinations) based on Hospitals field.
... View more
05-29-2013
09:15 AM
|
0
|
0
|
379
|
POST
|
You could make an OLEDB connection to the SQL Server and geocode off of that. Then use the add XY Coordinates tool to get the XY Coordinate you want.
... View more
10-10-2012
01:28 PM
|
0
|
0
|
96
|
POST
|
Hello All, I have a feature that has 561,000 geocoded points in 2 adjoining counties. I am looking to find a location or area that would best serve all of the points. I would preferably like to base it on drive time and/or drive distance(I have a network dataset with time and distance attributes). I am using ArcGIS 10 with Spatial and Network Analysis extensions. I am having a total mental block on where to begin. Any ideas on how to achieve this would be appreciated. Thanks
... View more
07-13-2012
10:43 AM
|
0
|
0
|
282
|
POST
|
Your project sounds very interesting. I would try to get the parcel data from the 3rd county if possible. From the parcel data make a single house address locator. Then you can geocode the students that need transportation (I'm assuming you have a list of them) and use that feature as an input for you network analysis. What attributes do your streets have? Do they have MPH? Without MPH, you won't be able to calculate time for you network. Do they have address ranges? If so, you can create a single-range or dual-range address locator depending on the data. Creating a composite address locator of the parcels and streets, you should be able to gecode a majority of the students accurately. I think this is the most important part. If you can't accurately locate the students, what good is it to make bus routes for them. To determine bus routes, you might look into using the location-allocation analysis layer. I'm not too familiar with location-allocation, but it might help. Once you determine bus stops, as Jay said, use the VRP analysis layer. I hope this helps give you some ideas on how to proceed. Good luck!
... View more
06-26-2012
01:48 PM
|
0
|
0
|
549
|
POST
|
For anyone interested, I found a script here that does what I need. I updated it to work with arcpy and added parameters to make it a script tool. import arcpy
from arcpy import env
import os.path
in_dir = arcpy.GetParameterAsText(0)
out_dir = arcpy.GetParameterAsText(1)
env.workspace = in_dir
input_tables = arcpy.ListTables()
vtab = arcpy.ValueTable()
for table in input_tables:
vtab.addRow(os.path.join(in_dir, table))
merged_table = os.path.join(out_dir)
arcpy.Merge_management(vtab, merged_table, '')
... View more
06-19-2012
11:00 AM
|
0
|
0
|
707
|
POST
|
Thank you for you reply. There is an Iterator in a nested model that performs the OD Cost Matrix. I tried using Collect Values to add the tables created from the copy rows within the Iterator as the input for the Merge. The Merge Tool shows the Tables I want to Merge in the Input Dataset section, and shows the fields in the Field Map section, but the Merge fails with: -ERROR 000622: Failed to execute (Merge). Parameters are not valid. -ERROR 000734: Inputs Datasets: 'all Tables created by Copy Rows(5 of them)' does not exist or is not supported. Failed to execute (Merge). The Tables do exsist and the paths to them are shown correct in the Merge's Input Dataset section. I get the same errors with the Append Tool. All 5 Tables I want to Merge are from the Lines of the OD Cost Matrix and all have the same fields. All 5 exsist in the same GDB and are the only things in it. Thanks [ATTACH=CONFIG]15300[/ATTACH][ATTACH=CONFIG]15301[/ATTACH]
... View more
06-18-2012
10:20 AM
|
0
|
0
|
707
|
POST
|
I have a model that creates multiple tables in a file geodatabase that are the results of an OD cost matrix. I need to merge all of the tables in to one. I want to be able to do this automatically as the number of tables and their names will change. How can I add all of the tables into the Merge Tool automatically? I would like to stay in the model environment as I am not very experienced in python. Any ideas on how to do this? Thanks!!!
... View more
06-15-2012
01:34 PM
|
0
|
4
|
4648
|
POST
|
Hi Jay, Thanks for the reply. Based on your response, I was able to figure it out. Instead of doing relates, I joined the tables, exported them, and geocoded the new table. Loaded the Members with OID as the ROUTENAME and my new geocoded layer with OID as the ROUTENAME and it worked perfectly!
... View more
01-09-2012
02:36 PM
|
0
|
0
|
292
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|