1

I have one SHP file containing polygons that describe splitlines in rows and cols. I'd like to use this to split an existing dataset of a few hundred SHPs containing tree positioning data. The extends of the tree SHP files do not match those of the split SHP. It is therefore likely that contents from various SHPs will (should) be written in one of the split tiles SHPs.

My setup in Modelbuilder is as follows: enter image description here

Problem now is that the split tool overwrites previously created SHPs when when moving on to new iterations of the tree SHPs.

"Collect Values" doesn't work as the resulting files are named by the split field attribute which I can't pull from the split tool.

Same applies for inline variables as described here. Since I cannot pull the name of the created SHPs from the split tool.

I also checked Geoprocessing options and overwrite is turned off.

Any ideas how to avoid the split tool to overwrite duplicates?

asked Aug 28, 2018 at 7:38
2
  • I tried creating a feature dataset for each iteration, using Name from Iterate Feature Classes and then use the feature dataset as output workspace in Split but it only splits first fc. You could try this, could be something wrong with my data. Is arcpy an option? If so i can post an answer Commented Aug 28, 2018 at 8:30
  • Thanks! I will try that. I have trouble setting up Arcpy on my system but I can give it another try if you have an idea how to solve it with Arcpy. Commented Aug 29, 2018 at 0:33

1 Answer 1

1

An alternative to ModelBuilder is to use ArcPy. Output from Split tool is written to in_memory workspace then renamed when copied to disk.

import arcpy,os,ntpath
input_workspace = r'C:\Test\Inputshapes'
splitpolygons = r'C:\Test\splitpolygons.shp'
splitfield = 'Splitfield'
output_workspace = r'C:\Test\Outputshapes'
arcpy.env.workspace = input_workspace
featurelist = [os.path.join(arcpy.env.workspace, f) for f in arcpy.ListFeatureClasses()] #List all shapes in input workspace
arcpy.env.workspace = r'in_memory'
for feature in featurelist:
 arcpy.Split_analysis(in_features=feature, split_features=splitpolygons, split_field=splitfield, out_workspace=r'in_memory') #Split into in_memory workspace
 memoryfeatures = arcpy.ListFeatureClasses()
 for f in memoryfeatures:
 arcpy.CopyFeatures_management(in_features=f, out_feature_class=os.path.join(output_workspace,ntpath.basename(feature).split('.')[0]+'_'+f)) #Copy to ouput workspace using a combination of original feature name and new name from Splitfield as output name
 arcpy.Delete_management(r'in_memory')

Example

answered Aug 29, 2018 at 4:57
1
  • Thank you! I just figured that Spatial Join runs about 4 times faster when assigning tree points to a particular polygon area (respectively inheriting its LatLon attributes) so I think I will drop the idea of using Split for this. My next problem are nested iterations, but I opened another topic for that here: gis.stackexchange.com/questions/294563/… Commented Aug 31, 2018 at 2:01

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.