1

In ArcGIS Pro, the 'Clip' tool deletes the parts of the input features that do not overlap the clip features.

I want to delete the parts of the input features that DO overlap the clip features. So, the inverse (or reverse) of what the 'Clip' tool does.

Ie, like the 'Erase' tool does, but without the Advanced license (which is required for Erase) and without having to install third party tools.

I'd be OK with using either Model Builder or arcpy for this to build my own tool. But the solution needs to be automatable and able to be repeated easily, like running a tool (so probably should involve actually building a tool).

Some of the answers in Performing reverse clip in ArcMap come close but they are either require Advanced Licence, third party tools or manual editing (eg, manual creation of a mask feature).

NB: Some proposed solutions that I've seen in various places (and actually used in the past, myself) involve the use of the 'Union' tool. This works quite well for Polygon inputs. However, it does NOT work for line or point inputs. I need a solution that works for all shape types.

Son of a Beach
  • 8,182
  • 1
  • 17
  • 33

3 Answers3

2

In ArcGIS Pro Pairwise Erase is available with a Basic license and can be used interchangeably with erase:

Computes a pairwise intersection of the input and erase features. Only those portions of the input features falling outside the erase features will be copied to the output feature class.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Mark Bryant
  • 1,435
  • 8
  • 7
  • 1
    That tool doesn't exist in ArcGIS Pro 2.8 which is what I'm using, so I hadn't heard of it before. But that's great to know, as I'm planning to upgrade to 3.0 soon - in which case all my work to create my own tool will have been wasted! :-( Thanks for pointing this one out. – Son of a Beach Dec 06 '22 at 23:34
  • @SonofaBeach It's toolbox history at https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/analysis-toolbox-history-pro.htm suggests it was added at 2.7 and that's supported by its archived documentation at https://pro.arcgis.com/en/pro-app/2.7/tool-reference/analysis/pairwise-erase.htm# – PolyGeo Dec 07 '22 at 03:35
  • @PolyGeo ...doh! Oh my goodness... you're right! It is right there in my 2.8. I feel really silly now, and should probably just close this question. For some reason I didn't notice it in my earlier searches (probably just didn't look any further than the other 'Erase' tool). And for some reason, the documentation (linked in the answer above), only includes 2.9 onwards in the 'Other Versions' options (which is why I mistakenly thought it started at 2.9). I've now accepted this as the correct answer. – Son of a Beach Dec 07 '22 at 22:27
  • @SonofaBeach I'd overlooked that Pairwise Erase was available at Basic so I'm very glad you asked (and answered) your question that not only gave us an ArcGIS Pro Q&A which is better than the equivalent one for ArcMap but made us all think harder. Kudos to MarkBryant for bringing this tool and its licensing to all of our attention. – PolyGeo Dec 08 '22 at 04:01
  • @PolyGeo - Yep... and I guess my own answer (ie, the model I built) is probably workable in ArcMap as a custom-built tool where the Pairwise Erase is not available. Maybe I should post it as an answer there. :-) (Although I haven't double-checked that all of its components are available in ArcMap.) – Son of a Beach Dec 09 '22 at 01:27
1

It turns out that a fully automated tool solution is possible using nothing more than ArcGIS Pro's built-in tools. Here's my solution using a Model Builder tool (click image to see it more clearly):

enter image description here

(Technically, that last 'Delete', to delete the temporary layer, is not required. I just like to tidy things up as I go along.)

This is how it works:

  • Generate an envelope feature that covers the extent of all the input features (Mimimum Bounding Geometry tool)
  • Union the Envelope feature (layer) with the Clip feature layer (Union tool)
  • Delete the Union features that are not within the Clip features (*see details of this process, below); what remains is the inverse of the clip features (within the envelope area), ie, a mask that can now be used for a normal clip
  • Run the ArcGIS Pro's normal built-in 'Clip' tool against the Input features using the automatically generated inverse clip mask as the Clip features

*To delete the Union features that are within the Clip features:

  • Calculate the name of the Union features field that represents the clip features FID (AKA ObjectID) (**see calculation below)
  • Create a temporary layer (Make Feature Layer) of the Union features with SQL expression: "%Clip FID Field% <> -1")
  • Delete all the Union features in the temporary feature layer

**Calculate Field Expression:

derivedFIDField("%Clip Features%")

**Calculate Field Block:

import os

def derivedFIDField(layer): path = arcpy.Describe(layer).catalogPath fc = os.path.basename(path) fcName = fc.split(".")[-1] return "FID_" + fcName

Son of a Beach
  • 8,182
  • 1
  • 17
  • 33
1

Field calculator solution I posted for polygons at ArcGIS method to partially erase or clip thousands of related polygons IS working for other shapes. For example:

enter image description here enter image description here

Modified version of expression:

hullsDict = {label:feat for label,feat in arcpy.da.SearchCursor("hulls",("label","Shape@"))}
tDict = {label:feat for label,feat in arcpy.da.SearchCursor("target",("label","Shape@"))}
def getSegment(ID):
  pair = hullsDict[ID]
  shp = tDict[ID]
  m=shp.difference (pair)
  return  m
#-----
getSegment(!LABEL!)

Can be even shorter but ArcGIS struggles with

getSegment(!LABEL!,!Shape!)
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
FelixIP
  • 22,922
  • 3
  • 29
  • 61