|
POST
|
How are you running the code? Is is with a script tool, a model, or the python window?
... View more
10-01-2015
03:21 PM
|
1
|
3
|
3069
|
|
POST
|
Hi Hazel, Are you by any chance familiar with python? You could use excel to create the permutations or even have them written down in notepad, but taking these approaches is going to result in you having to manually input this information into your model. I would highly suggest using python to accomplish this task. Within python creating the permutations is a one line call. For example, I'm not sure how well you understand python, but I have included code below that I was able to utilize to create the results you're seeking. You can review this if you want to utilize this workflow to accomplish your task. I pulled the example from the page listed below and modified it. Make Route Layer http://desktop.arcgis.com/en/desktop/latest/tools/network-analyst-toolbox/make-route-layer.htm # Name: MakeRouteLayer_Workflow.py
# Description: Find a best route to visit the stop locations and save the
# route to a layer file. The stop locations are geocoded from a
# text file containing the addresses.
# Requirements: Network Analyst Extension
# Import system modules
import arcpy
import itertools
import os
from arcpy import env
try:
dataPath = os.path.join(os.path.dirname(__file__), "data")
# Check out the Network Analyst extension license
arcpy.CheckOutExtension("Network")
# Set environment settings
env.workspace = os.path.join(dataPath, "SanFrancisco.gdb")
env.overwriteOutput = True
# Set local variables
inNetworkDataset = "Transportation/Streets_ND"
outNALayerName = "BestRoute"
impedanceAttribute = "TravelTime"
outStops = "Analysis/Stores"
outLayerFile = os.path.join(dataPath, "output", outNALayerName + ".lyr")
if arcpy.Exists(os.path.dirname(outLayerFile)):
arcpy.management.Delete(os.path.dirname(outLayerFile))
os.makedirs(os.path.dirname(outLayerFile))
# Create a new Route layer. For this scenario, the default value for all the
# remaining parameters statisfies the analysis requirements
outNALayer = arcpy.na.MakeRouteLayer(inNetworkDataset, outNALayerName, impedanceAttribute)
# Get the layer object from the result object. The route layer can now be
# referenced using the layer object.
outNALayer = outNALayer.getOutput(0)
# Get the names of all the sublayers within the route layer.
subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
# Stores the layer names that we will use later
stopsLayerName = subLayerNames["Stops"]
# Load the geocoded address locations as stops mapping the address field from
# geocoded stop features as Name property using field mappings.
fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, stopsLayerName)
fieldMappings["Name"].mappedFieldName = "NAME"
# Get a list of all of the OIDs for the stops we need to create a route against
oidfieldname = arcpy.Describe(outStops).oidfieldname
with arcpy.da.SearchCursor(outStops, ["OID@"], "{} < {}".format(*[oidfieldname, 6])) as cursor:
oids = [row[0] for row in cursor]
# Get all of the permutations for all of the stops except the start/end
permutations = list(itertools.permutations(oids[1:-1], len(oids)-2))
stopsLayer = arcpy.management.MakeFeatureLayer(outStops, "LoadOrder")
for n,stops in enumerate(permutations):
# Add the start stop
arcpy.management.SelectLayerByAttribute(stopsLayer, "NEW_SELECTION", "{} = {}".format(*[oidfieldname, oids[0]]))
arcpy.na.AddLocations(outNALayer, stopsLayerName, stopsLayer, fieldMappings, "", exclude_restricted_elements="EXCLUDE",
append="CLEAR")
# Add the in-between stops in the permutation order
for i, stop in enumerate(stops):
arcpy.management.SelectLayerByAttribute(stopsLayer, "NEW_SELECTION", "{} = {}".format(*[oidfieldname, stop]))
arcpy.na.AddLocations(outNALayer, stopsLayerName, stopsLayer, fieldMappings, "", exclude_restricted_elements="EXCLUDE",
append="APPEND")
# Add the end stop
arcpy.management.SelectLayerByAttribute(stopsLayer, "NEW_SELECTION", "{} = {}".format(*[oidfieldname, oids[-1]]))
arcpy.na.AddLocations(outNALayer, stopsLayerName, stopsLayer, fieldMappings, "", exclude_restricted_elements="EXCLUDE",
append="APPEND")
# Solve the route layer, ignore any invalid locations such as those that
# can not be geocoded
arcpy.na.Solve(outNALayer,"SKIP")
# Save the solved route layer as a layer file on disk with relative paths
arcpy.management.SaveToLayerFile(outNALayer,outLayerFile.replace(".lyr", "_{0}.lyr".format(str(n+1).zfill(len(
permutations)))),"RELATIVE")
print("Script completed successfully")
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print("An error occured on line %i" % tb.tb_lineno)
print(str(e))
As a side note, if you wanted you could take lines 52-83 from my code, convert it into a script tool and then use this within a Model to implement the advanced logic needed here to execute the task. This iteration logic would not be natively possible to implement within ModelBuilder.
... View more
09-30-2015
04:31 PM
|
1
|
0
|
2697
|
|
POST
|
import arcpy
i = 0
fields = ["LastName", "FirstName"]
values = ["Jensen", "Parky"]
# Option A
with arcpy.da.UpdateCursor(table, fields, where) as cursor:
for row in cursor:
while (i < len(fields)):
row = values
i+=1
i=0
cursor.updateRow(row)
# Option B
with arcpy.da.UpdateCursor(table, fields, where) as cursor:
for row in cursor:
for i,value in enumerate(values):
row = value
cursor.updateRow(row)
... View more
09-30-2015
09:30 AM
|
0
|
4
|
3626
|
|
POST
|
Have you tried modifying the Enabled property of the button using your logic to check if the editor is active within the OnUpdate method of the button. Esri.ArcGIS.Desktop.Addins.Button http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/#/Button_Class/001v000000r4000000/
... View more
09-29-2015
05:04 PM
|
1
|
1
|
1755
|
|
POST
|
Could you describe the variable you're needing to set? If these buttons/tools are within the same project you could create a global variable within their source code and initialize it within the constructor of the buttons/tools.
... View more
09-29-2015
09:27 AM
|
1
|
3
|
1755
|
|
POST
|
Have you tried using the pageRow returned from the data driven pages class? DataDrivenPages (arcpy) http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/datadrivenpages-class.htm
... View more
09-29-2015
09:08 AM
|
1
|
5
|
1802
|
|
POST
|
The signature for this class hasn't changed between the 10.x versions. I'd assume that the intellisense in Visual Studio is showing you the unmanaged signature for this assembly. The geoprocessor should provide you with the following signatures: Geoprocessor.Execute(IGPProcess, ITrackCancel) // Managed Geoprocessor.Execute(String, IVariantArray, ITrackCancel) // Unmanaged All of the relevant information about running a managed or unmanaged tool should be available on the following page. How to run a Geoprocessing tool http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000003rr000000
... View more
09-27-2015
06:57 PM
|
1
|
1
|
1713
|
|
POST
|
Out of the box modelbuilder wouldn't allow you to do this without manually setting up all of your permutations for your routes. I would think that what you'd want to do is develop a script tool that can return a list of all of your different route permutations and then use a submodel with an iterator to solve for each of these permutations.
... View more
09-27-2015
06:24 PM
|
1
|
0
|
2697
|
|
POST
|
Are you only needing to modify the data and display the data in runtime? If yes you could leverage a runtime geodatabase (i.e. the file that ends with the .geodatabase extension). If you wanted to use a shapefile you could load the data into runtime and manipulate it, but you would not be able to persist the data changes back to the source shapefile. Creating ArcGIS Runtime Content http://desktop.arcgis.com/en/desktop/latest/map/working-with-arcmap/creating-arcgis-runtime-content.htm
... View more
09-25-2015
09:02 AM
|
0
|
1
|
2882
|
|
POST
|
Yea...I would think that the solution would work the same for a single or multiple vehicles. The catch will be if Hazel knows exactly where these riders are going. If so, then ordered pairs can be created for the passengers to limit the time they're on the bus. I would think that a Order Pair based VRP solution would be what is needed because Hazel needs to manage MaxTransitTime for each person or group of people on the vehicle.
... View more
09-25-2015
08:44 AM
|
0
|
0
|
2667
|
|
POST
|
I believe that the tutorial I've listed below solves an issue similar to this. Exercise 8: Finding best routes to service paired orders http://desktop.arcgis.com/en/desktop/latest/guide-books/extensions/network-analyst/exercise-8-finding-best-routes-to-service-a-set-of-paired-orders.htm The primary goal of the able exercise is to find the best routes for a fleet of vans to transport people to different hospitals for medical appointments. This exercise also implements a max transit time so that riders don't spend too much time in transit.
... View more
09-25-2015
08:33 AM
|
0
|
4
|
2667
|
|
POST
|
For personal geodatabases the answer would be no because the Runtime APIs do not support personal geodatabases. I've pointed to the documentation that states this below. Although runtime won't allow you to edit personal geodatabases directly, I may be able to point you to another workflow that would allow you to adopt this API. Could you provide more information on the workflow you're needing to accomplish with the runtime sdk? Also, do you have access to ArcGIS Server? Supported Geodatabase Formats https://developers.arcgis.com/net/desktop/guide/supported-geodatabase-formats.htm
... View more
09-25-2015
08:23 AM
|
0
|
3
|
2882
|
|
POST
|
WorkspaceFactoryType would not contain an enum for Personal Geodatabases. You'd need to convert your data to either a shapefile or a file/enterprise geodatabase.
... View more
09-25-2015
08:03 AM
|
0
|
1
|
2882
|
|
POST
|
IWorkspaceFactory belongs to the ArcObjects SDK (i.e. Esri.ArcGIS.Geodatabase.IWorkspaceFactory). IWorkspaceFactory http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//002500000m9w000000 Are you wanting to use ArcObjects or the ArcGIS for Runtime SDK. The runtime SDK would not utilize this interface. What type of workspace are you needing to open? If you're using the Runtime SDK I'd assume you're referring to Esri.ArcGISRuntime.LocalServices.WorkspaceFactoryType enumeration. WorkspaceFactoryType Enumeration https://developers.arcgis.com/net/desktop/api-reference//html/T_Esri_ArcGISRuntime_LocalServices_WorkspaceFactoryType.htm The above interface is what you'd use in runtime to specify the workspace type when creating a dynamic workspace.
... View more
09-24-2015
06:07 PM
|
0
|
3
|
2882
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-19-2016 04:45 AM | |
| 1 | 09-24-2015 06:45 AM | |
| 1 | 09-15-2015 10:49 AM | |
| 1 | 10-12-2015 03:07 PM | |
| 1 | 11-25-2015 09:10 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|