Question

How can I get the segment atributes from the polygon path segmenter transformer


I have tried to use the polygon path segmenter to get the number of line segments in a set of polygons. I can see that it is creating a segment attribute when I go into the attribute properties on the inspector however I can't seem to get these attributes to come through into my routine. I have tried exposing them in different ways but to no avail. Is anyone able to help please? I'm sure it must be something simple I am missing!

Thanks


5 replies

Userlevel 1
Badge +21

The polygon path segmenter changes the geometry into path segments, it doesn't actually create any attributes.

What are you trying to get? A line segment count, or the coordinates of each line segment?

@ebygomm I'm after the line segment count....I can see it in the attribute properties which is why I thought I must be able to get it out of there but maybe not. I've tried doing it by vertices but the number is incorrect due to having multiple vertices along one line, which is why the polygon path segmenter works better because I can set the angle. I've tried a path splitter to get the segment count after which gives me nothing...is there something else I can do to get it?

Thanks

Userlevel 1
Badge +21

@ebygomm I'm after the line segment count....I can see it in the attribute properties which is why I thought I must be able to get it out of there but maybe not. I've tried doing it by vertices but the number is incorrect due to having multiple vertices along one line, which is why the polygon path segmenter works better because I can set the angle. I've tried a path splitter to get the segment count after which gives me nothing...is there something else I can do to get it?

Thanks

I think the part counter after the polygon path segmenter will give you the count of paths/segments

Userlevel 1
Badge +21

I think the part counter after the polygon path segmenter will give you the count of paths/segments

Although after checking, this doesn't seem to count the parts correctly where the geometry is a polygon made up of path segments. You can coerce to a line first to get the parts correctly (and then back to an area again afterwards) but it may be worth asking the question of safe as to whether the partcounter should count the segments in a polygon made up of paths

Badge +22

I would be tempted to edit the PolygonPathSegmenter to output this number.  I think it would be in the AreaBuilder,  Generate a list and then ListElementCounter.

In the generic case for counting the number of segments of a polygon, I would use this python snippet.

def processFeature(feature):
    geom = feature.getGeometry()
    path = geom.getBoundaryAsCurve()
    ct = path.numParts()
    feature.setAttribute("_segments",ct)

Reply