I have a feature class of polygons (ImportPoly), each of them is intersected by line from (ImportLine) and then new polygons created in (OutPoly) feature class with all attributes saved. I need to cut each polygon with only one line that has same [cut_field] as [cut_field] of polygon. Methods described here and here don't really work for me, because each poly must be splitted only with corresponding line.

Is there a way to write something like "search cursor in ImportPoly and ImportLine, if cut_fields are equal then use Feature to Polygon tool for them"? picture to illustrate

Edit: solution by @Hornbydd works perfectly in any way but time. Each iteration took roughly 10 seconds, which would become great amount of time for large datasets.


So for your line data you have a field called cut_field which lets say holds a numeric ID value and for your polygon dataset it too has a field called cut_field which holds a corresponding ID? The issue here is that your polygons are overlapping and in some cases entirely overlapping 1 or more.

To process such a dataset you need to process them one polygon at a time, do the cut and I assume merge all the split polygons back into a single dataset?

You don't say how many polygons you want cut, a few hundred or billions? This obviously dictates what sort of solution you are going to get from the GIS community! I am going to assume just a few hundred, so a model builder solution will be adequate with no python code required.

A fairly simply model, which relies on you having an advance level license can achieve this.

I can turn this:


into this:

enter image description here

Using the following model:


A final optional step (not shown) is to merge the outputs back into a single Feature Class.

The model is iterating over your cut_field values and using those to select a single line and a single polygon. As all geoprocessing tools honour selections it is only these two geometries that are fed into the Feature to Polygon tool for doing the cut. Finally the model adds a new field and populates with the cut_field ID coming out of the iterator so you have a link to the original data.

  • I have arond 1500 polygons. Yes, line and polygon sets both have field with corresponding ID. Do I need to sort both datasets ascending by this field before starting model? Your example looks just like I need it to work, thanks you! – Николай Слодарж Jul 4 '20 at 17:08
  • No sorting required. – Hornbydd Jul 4 '20 at 17:26
  • Sorry to bother, but how do you add Count variable in MB? – Николай Слодарж Jul 4 '20 at 18:17
  • Count what and what do you want to do with it? – Hornbydd Jul 4 '20 at 19:05
  • Your model has Counts after Select Layer by Attribute, I assume it should display number of iteration? – Николай Слодарж Jul 4 '20 at 20:34

If 1500 classes is too much to merge, try this:

import arcpy
aDict = {}
def splitMe(shp, BID):
    cutLine = aDict[BID]
    two = shp.cut(cutLine)
    if len(two)==2:return two
    return shp
with arcpy.da.SearchCursor("lines",("Shape@","ID")) as cursor:
    for line,idn in cursor:
with arcpy.da.UpdateCursor("polygons",("Shape@","ID")) as cursor:
    for pgon,idn in cursor:
        twoParts = splitMe(pgon, idn)
        lArray = twoParts[0].getPart(0)
        newPgon = arcpy.Polygon(lArray)

to obtain parts of polygon to the right side of cut line. Change to twoParts[1] to obtain parts on the left. Work on the copies of original, because script modifies shapes in place.

Script uses "cut" method for geometry object:

enter image description here

Unfortunately this method as well (bad?) as many others is not working inside field calculator expression. It's a shame because, above script can be replaced by significantly shorter expression.

BTW: what kind of surface is underneath?

  • Thanks, I will try using this as well! It's Moon's DTM by LOLA, I'm doing a research of South Pole craters – Николай Слодарж Jul 7 '20 at 14:16

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.