Calculating distance between many users of a handful of facilities, a small hangup

4666
11
02-07-2015 10:23 AM
chriscoutts
New Contributor

I know the ROUTENAME issue has been addressed many times in these forums over the past couple years.  I have scoured them and am hung up on one point.

 

In the shortest distance thread it is stated that "You might have to load multiple copies of the same park because multiple people use the same park."  In my case, these are facilities.

 

In the Re: Finding Distances Between Assigned Locations thread it is stated that "...your 368 locations are repeating. You could do this with some relates...", but there is not direction on how to use relates to generate repeated "locations."

 

I need to figure out how to make hundreds of duplicate copies of the same facility.  Once duplicated, I will then give each one of the hundreds of copies of the same facility a unique ID.  Then I can match the facility to the thousands of users of it using ROUTENAME.

 

It is just duplicating the facility that is hanging me up.  Please help.  Thanks.

Tags (2)
0 Kudos
11 Replies
DarrenWiens2
MVP Honored Contributor

If I'm reading this right, your main question is how to duplicate geometries. Here's how, using Python:

>>> duplicates = 100
>>> points = []
>>> with arcpy.da.SearchCursor("YOUR_POINT_LAYER_NAME",["SHAPE@"]) as cursor:
...    for row in cursor:
...        for i in range(duplicates):
...            points.append(row[0])
...           
>>> arcpy.CopyFeatures_management(points,'in_memory\out_points')
<Result 'in_memory\\out_points'>
>>> arcpy.SpatialJoin_analysis("out_points","YOUR_POINT_LAYER_NAME",r'in_memory\sp_join_output',"JOIN_ONE_TO_ONE","KEEP_ALL",'#',"ARE_IDENTICAL_TO")
<Result 'in_memory\\sp_join_output'>
0 Kudos
chriscoutts
New Contributor

I really appreciate the prompt response.  Thanks very much.

In one feature class (facilities) I have 19 individual points.  I am trying to make hundreds of copies of each point (facility).  Will the script you provided tackle this?  If so, I'm a novice GIS user, could you tell me where to plug in this script?  Thanks again, Darren.

0 Kudos
DarrenWiens2
MVP Honored Contributor

This script will make 100 copies of each feature in the feature class "Your point layer name" (of course, change that to your later name). Change the number of duplicates if you want.

This script can go into the Python window, accessed under the geoprocessing menu in ArcMap.

0 Kudos
chriscoutts
New Contributor

Beautiful.  I am going to give it a run, but it may be a couple days before I can get back to it.  Thanks so much.

0 Kudos
chriscoutts
New Contributor
Runtime error  Traceback (most recent call last):   File "<string>", line 1, in <module>   File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\analysis.py", line 481, in SpatialJoin raise e ExecuteError: ERROR 000732: Target Features: Dataset out_points does not exist or is not supported ERROR 000732: Join Features: Dataset ex_centroid does not exist or is not supported 

This is what is spit back at me.  Running now, but will go back through the code to make sure I put in exactly what you provided.

0 Kudos
DarrenWiens2
MVP Honored Contributor

That was my fault - I ran my test on a feature class called "ex_centroid". I've updated the script to say "YOUR_POINT_LAYER_NAME" in the Spatial Join call (so, change that to your own).

0 Kudos
chriscoutts
New Contributor

I was really excited about getting this working, but I am failing right in line 1 somehow.  Here's a screenshot:

I am really put some time into trying to understand where I was failing before bugging you, but I am stuck.

0 Kudos
DarrenWiens2
MVP Honored Contributor

You need matching quotes around "SHAPE@"

0 Kudos
XanderBakker
Esri Esteemed Contributor