3

Looked around and found other Cursor questions, but nothing dealing with updating 'SHAPE@LENGTH'. I am running ArcGIS 10.2.1 and have a multipoint shapefile that I am grouping into polygons based on a shared attribute. However, sometimes only one point has the attribute and so a very tiny polygon is drawn, as described by the minimum bounding geometry documentation (http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000003q000000).

I wanted to loop through the new polygon shapefile and use Update Cursor to access the tiny polygons' Geometry ('SHAPE@LENGTH') and bump it up to a visible level. I am unfortunately not understanding something because the changes to the length are not saved. I figured it would be harder than just reassigning the area value, but so far I can't understand what is going wrong:

import os
import arcpy

# Point data directory
polyFiles = 'C:\Users\...polyFiles'

# Polygon file made from the points
boxes = os.path.join(polyFiles, 'OE_AK_poly.shp')

# If length is less than 1000m bump it up so it's visible on the map
with arcpy.da.UpdateCursor(boxes, ["SHAPE@LENGTH"]) as cursor:
    for row in cursor:
        if row[0] < 1000:
            row[0] = 1000
        cursor.updateRow(row)
4
  • What's your end goal here?
    – ianbroad
    Apr 2, 2014 at 16:53
  • Why not buffer the polygons by X that meet your if statement criteria?
    – Aaron
    Apr 2, 2014 at 16:55
  • my end goal is for the tiny polygons to have a visible symbol on the map ("If length is less than 1000m bump it up so it's visible on the map").
    – sclarky
    Apr 2, 2014 at 19:57
  • My work around has been to buffer the polygons but it's an ugly script-- the Buffer tool will exclude anything that I do not want to buffer so it devolved into multiple files, some with buffered polygons, some not, then having to rejoin them.
    – sclarky
    Apr 2, 2014 at 19:58

1 Answer 1

8

In cursors, length is a read-only property.

I couldn't imagine what a predictable outcome would be for setting a new length of a line. Would it just extend the last point out in the bearing from the next to last point? What if it were multipart? Would it grow the entire polyline segment by segment?

3
  • 2
    ...so, you probably want to run Buffer on those tiny polygons to get them larger. Feels to be the easiest way to me. Apr 2, 2014 at 16:28
  • 2
    Or a more aggressive symbology if it's just a visual thing Apr 2, 2014 at 16:32
  • cool...'read only' is the thing I was missing. Thanks. The buffering and symbology options I have both used, they're just not very elegant
    – sclarky
    Apr 2, 2014 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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