Skip to main content
added 680 characters in body
Source Link
FelixIP
  • 23.3k
  • 3
  • 31
  • 62

Perhaps run this calculator expression on field Shape of your target:

def getSegment(ID):
 f = arcpy.AddFieldDelimiters("HULLS","LABEL")
 q="%s='%s'" %(f,ID)
 with arcpy.da.SearchCursor("HULLS", 'Shape@',q) as cursor:
  for row in cursor:  pair=row[0]
 with arcpy.da.SearchCursor("TARGET", 'Shape@',q) as cursor:
  for row in cursor:  shp=row[0]
 m=shp.difference (pair)
 return m
#---------------
getSegment( !Label! )

BEFORE:

enter image description here

AFTER:

enter image description here

Python expression above assumes:

  • your target layer is stored as shapefile and named "TARGET" in the table of current mxd.
  • eraser layer stored as shapefile and named "HULLS" in the table of current mxd.
  • Common field in both layers is text field called "Label". If this not a case create such field in both and populate them from existing common fields.

NOTE: script modifies shapes in existing target layer, so create backup copy first.

First learn how to use advanced field calculator in arcgis.

Perhaps run this calculator expression on field Shape of your target:

def getSegment(ID):
 f = arcpy.AddFieldDelimiters("HULLS","LABEL")
 q="%s='%s'" %(f,ID)
 with arcpy.da.SearchCursor("HULLS", 'Shape@',q) as cursor:
  for row in cursor:  pair=row[0]
 with arcpy.da.SearchCursor("TARGET", 'Shape@',q) as cursor:
  for row in cursor:  shp=row[0]
 m=shp.difference (pair)
 return m
#---------------
getSegment( !Label! )

BEFORE:

enter image description here

AFTER:

enter image description here

Perhaps run this calculator expression on field Shape of your target:

def getSegment(ID):
 f = arcpy.AddFieldDelimiters("HULLS","LABEL")
 q="%s='%s'" %(f,ID)
 with arcpy.da.SearchCursor("HULLS", 'Shape@',q) as cursor:
  for row in cursor:  pair=row[0]
 with arcpy.da.SearchCursor("TARGET", 'Shape@',q) as cursor:
  for row in cursor:  shp=row[0]
 m=shp.difference (pair)
 return m
#---------------
getSegment( !Label! )

BEFORE:

enter image description here

AFTER:

enter image description here

Python expression above assumes:

  • your target layer is stored as shapefile and named "TARGET" in the table of current mxd.
  • eraser layer stored as shapefile and named "HULLS" in the table of current mxd.
  • Common field in both layers is text field called "Label". If this not a case create such field in both and populate them from existing common fields.

NOTE: script modifies shapes in existing target layer, so create backup copy first.

First learn how to use advanced field calculator in arcgis.

Source Link
FelixIP
  • 23.3k
  • 3
  • 31
  • 62

Perhaps run this calculator expression on field Shape of your target:

def getSegment(ID):
 f = arcpy.AddFieldDelimiters("HULLS","LABEL")
 q="%s='%s'" %(f,ID)
 with arcpy.da.SearchCursor("HULLS", 'Shape@',q) as cursor:
  for row in cursor:  pair=row[0]
 with arcpy.da.SearchCursor("TARGET", 'Shape@',q) as cursor:
  for row in cursor:  shp=row[0]
 m=shp.difference (pair)
 return m
#---------------
getSegment( !Label! )

BEFORE:

enter image description here

AFTER:

enter image description here