0

I'm working in Arcmap10.3. I have some polygons layers that over lap that I want to merge to one polygon layer. Then I want to convert it to a raster in the end. I want the top layer of the 4 input layers to not be disturbed or converted to the same class as the lower layers. How do I go about doing this?

I've tried using the merge tool for the 4 polygon shapefiles. But it just runs into infinity.

  • @Tom see edits. – Hgotwald Mar 9 '16 at 0:22
  • 1
    First off, you probably want to look into some combination of Unioning, Erasing, and/or Intersecting instead of Merging. However, when you say it "runs into infinity", what do you mean? It ran for a long time? It crashed with a memory error? How many features are in your feature classes and how large are the files on disk? – Tom Mar 9 '16 at 0:26
1

The Overlay toolset is a great place to start. Suppose you have four feature classes and you wish to "flatten" them, with fc1 overwriting fc2 overwriting fc3 overwriting fc4. Then run the Erase tool with fc4 as the Input Features and fc3 as the Erase features. Then merge fc3 and the output feature class. Then, run the Erase tool, this time with the merged feature class from the previous step as the Input Features and fc2 as the Erase Features. Continue in that pattern.

When that's all done, run the Polygon to Raster tool.

For anyone interested in a python function using arcpy to accomplish the ranked-feature-class-flattening portion of this:

def merge_and_overwrite(inputFeatureClasses, outputFeatureClass):
    '''
    (list/tuple, str)

    Merge feature classes, erasing areas of overlap from lower ranking feature
        classes.

    Parameters:
    inputFeatureClasses - A list or tuple of feature class paths/names. Areas of
        overlap will be erased from the feature classes in the order in which
        the feature classes are listed. That is, passing ['Wetland', 'Riparian',
        'AOI'] would result in a feature class in which the portions of AOI
        features that overlap riparian or wetland features are erased from the
        AOI features; the portions of riparian areas that overlap wetland
        features are erased from the riparian features. These erased areas are
        still covered by features in the output feature class, but they are
        covered by the highest ranking feature at that location. Rank descending
        order from the passed list/tuple.
    outputFeatureClass - The path/name of the feature class to which you wish to
        write the output, erased/merged features.
    '''
    import os

    dirIM = 'in_memory'

    fcCurrent = inputFeatureClasses[0]

    for index in range(1, len(inputFeatureClasses)):
        fcOverwritten = inputFeatureClasses[index]
        # Erase the features to a temporary feature class in memory
        fcTemp = os.path.join(dirIM, '{}_Erased'.format(fcOverwritten))
        arcpy.Erase_analysis(fcOverwritten, fcCurrent, fcTemp)
        # Merge the feature class with the current cumulative erase/merge
        #   feature class
        fcMerged = os.path.join(dirIM, '{}_Merged'.format(fcOverwritten))
        arcpy.Merge_management([fcCurrent, fcTemp], fcMerged)

        # Set the variable names to refer to the next iteration
        fcCurrent = fcMerged

    # Save the cumulative erased/merged feature class
    arcpy.CopyFeatures_management(fcCurrent, outputFeatureClass)

    return outputFeatureClass

And, now that I look at this function I wrote some time ago, I'm sure there is a far more efficient way to accomplish this.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.