Skip to main content
Solved

Filter polygons composed of line+arc (preserve geometry)

  • Apr 15, 2019 5:07 PM UTC
  • 2 replies
  • 410 views

jpsalva
Contributor
Forum|alt.badge.img+3

I have a polygon dataset.

  • 90% of this dataset is polygons composed of lines
  • 10% of this dataset is polygons composed of lines+arcs.

How to I filter out the 10% lines+arcs records while keeping the geometry intact?

Best answer by takashi

A possible way is:

  1. Add unique ID attribute to every polygon.
  2. Split the feature flow into two streams. On the first stream, extract geometry; On the second stream, convert arcs (if exists) to polylines then extract geometry.
  3. Use the FeatureMerger to merge the second stream to the first stream, grouping by ID and using the geometry as join key.

Polygon boundaries output from the Merged port only consist of Lines, others consist of Lines and Arcs.

0684Q00000ArJk6QAF.png

 

Alternatively, a PythonCaller with this script works as well.

def processFeature(feature):
    area = feature.getGeometry()
    feature.setAttribute('_is_linear', 'yes' if area.isBoundaryLinear() else 'no') 

0684Q00000ArJUzQAN.png

View original
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • Best Answer
  • Apr 15, 2019 10:16 PM UTC

A possible way is:

  1. Add unique ID attribute to every polygon.
  2. Split the feature flow into two streams. On the first stream, extract geometry; On the second stream, convert arcs (if exists) to polylines then extract geometry.
  3. Use the FeatureMerger to merge the second stream to the first stream, grouping by ID and using the geometry as join key.

Polygon boundaries output from the Merged port only consist of Lines, others consist of Lines and Arcs.

0684Q00000ArJk6QAF.png

 

Alternatively, a PythonCaller with this script works as well.

def processFeature(feature):
    area = feature.getGeometry()
    feature.setAttribute('_is_linear', 'yes' if area.isBoundaryLinear() else 'no') 

0684Q00000ArJUzQAN.png


jpsalva
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • Apr 16, 2019 2:13 PM UTC

Thank you @takashi the python solution is elegant and exactly what I was looking for!