Import polygons with auto clip?

2799
11
02-02-2016 12:42 PM
BruceLang
Occasional Contributor III

This seems so basic, but I'm not finding a solution.

I have; (1) a polygon shapefile containing multiple polygons, and (2) a versioned enterprise geodatabase (SQL server) polygon layer.  The shapefile and geodatabase contain the same file structure.

I would like to import the shapefile polygons into the geodatabase AND remove (clip away) any overlap from the geodatabase layer.

The data layers consist of zoning polygons.  The geodatabase layer is the existing county zoning layer, covering the entire county.  The shapefile contains new zoning areas to import into the geodatabase layer.  The new areas must remove any overlapping area from the geodatabase layer.

I can do this manually in an edit session, but only one polygon at a time. (a) copy area from shapefile, (b) paste into geodatabase layer, and (c) select "clip" (from the editor menu) clipping away overlap from geodatabase.  When trying the same process with multiple polygon's, the clip option was not available.

Thanks in advance.

BTW: ArcGIS 10.3.1 Standard

0 Kudos
11 Replies
ChrisDonohue__GISP
MVP Alum

Erase (Analysis) doesn't work in a Versioned environment, unfortunately, due to the constraint on processes that create new data.  However, if you export your data to a File Geodatbase, you are free of the enterprise geodatabase limitations.  You can then do all the processing of the data, then Append the results back into the Version.

If you don't have the Advanced license required to have Erase available, there are several workarounds:

1. There's Python - see the script Darren Wiens posted.

2.  If you have XToolsPro (third-party software add-on), there is an Erase Features function.

3.  You can run a Union (Analysis) which is available at all license levels, and then go into the attribute table and do a selection to essentially recreate the results of an Erase.

The output feature class will contain a FID_<name> attribute for each of the input feature classes. For example, if one of the input feature classes is named Soils, there will be a FID_Soils attribute on the output feature class.  FID_<name> values will be -1 for any input feature (or any part of an input feature) that does not intersect another input feature. Attribute values for the other feature classes in the union where no intersection is detected will not be transferred to the output feature in this case.

ArcGIS Help 10.1 - Union (Analysis)

Chris Donohue, GISP

DarrenWiens2
MVP Honored Contributor

Here's a Python script that should emulate your manual editing task using geometry objects, in place, and Basic licensing. Caveats: I have no idea if this works for versioned data. This is a n^2 operation, meaning for each feature in the original dataset, it does something for each feature in the new dataset. This may be problematic for large datasets.

>>> main = 'main' # main dataset
... new = 'new' # new dataset
... with arcpy.da.UpdateCursor(main,'SHAPE@') as uCursor:
...    for uRow in uCursor: # loop through main polygons
...        with arcpy.da.SearchCursor(new,'SHAPE@') as sCursor:
...            for sRow in sCursor: # loop through new polygons
...                uRow[0] = uRow[0].difference(sRow[0]) # remove overlaps between main/new
...                uCursor.updateRow(uRow) # update main polygons minus new polygons
... arcpy.Append_management([new],'main',"NO_TEST") # append new polygons to main

Original (no overlaps):

With new shapefile overlain:

Delete 'differences' (no overlaps, voids for new features):

Append new to main (no overlaps):