0

I am running multiple conditional selections, both where clauses with attributes and location based selections. I want to build functions, possibly within classes that are reusable and can pipe to each other or be scripted in different orders based on workflow. I DON'T want to CopyFeatures_management constantly for intermediate features classes written to disc. I'm hoping for Python type:

temp = load_data(fp_data)
temp2 = function1(temp)
temp3 = function2(temp2)
CopyFeatures_management(temp3)

Simple example of current workflow:

def select_by_location(fp_select, fp_location, distance_string, fp_out):

    arcpy.MakeFeatureLayer_management(fp_select, 'in_lyr')
    arcpy.MakeFeatureLayer_management(fp_location, 'location_lyr')
    arcpy.SelectLayerByLocation_management('in_lyr', 'within_a_distance', 'location_lyr', '5 Miles')
    arcpy.CopyFeatures_management('in_lyr', fp_out)

Call function with first feature layer:

select_by_location(fp1, fp2, '5 Miles')

Now take output and select with another feature layer:

fp_location2 = 'path/to/another/file'

arcpy.select_by_location(fp_out, fp_location2, '3 Miles', fp_out2)

What is a good protocol to avoid saving to disc constantly when in ArcPy world?

2
  • 2
    You mean, instead of using the in_memory workspace? – Vince Jun 9 '20 at 1:33
  • That'll work. Thanks Vince! Took me a bit to respond because I have been grappling with the difference between in_memory workspace and simply using MakeFeatureLayer_management. I found a good post from Stack Exchange with good links and comments as well. Still slightly confused as to difference between MakeFeatureLayer_management and CopyFeatures_management with in_memory specified but alas...for another Q. Here is the link: gis.stackexchange.com/questions/72193/…) – NW_Photo_Laureate Jun 11 '20 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.