Question

analyzing polygons with polylineanalyzer

  • 24 March 2016
  • 2 replies
  • 5 views

Badge +1

Hello,

I need to analyse a number of polygons which represent buildings, the data i need is the inner corner of every point and the length of every segment. I'm using the polylineanalyzer to get this data and this works as long as the polygon is a solitary object. If another polygon is adjacent to the one being examined it seems that the common lines are being kept out of the examination in the polylineanalyzer. The number of lines which flow out of the polylineanalyzer are less than the total number of polygonsegments.

Has anyone an idea how to bypass this?

best regards & thanks


2 replies

Userlevel 2
Badge +17

Hi @ddecoene, I checked the definition of the PolylineAnalyzer and found that it doesn't compute segment angles as your expected if the vertex touches to multiple polygons.

This workflow calculates angles and azimuths of all segments of a polygon, and stores the results in a structured list attribute - _vertex{}.acAngleIn, .acAzimuthIn, .acAngle, .acAzimuth. Hope this helps.

0684Q00000ArLuEQAV.png

[Addition] Insert the LengthCalculator between the Chopper and AzimuthCalculator, to calculate the length of each segment. This is a Python version.

# PythonCaller Script Example
# Compute angle, azimuth and length for every segment of a polygon boundary,
# store the results in a structured list.
# The unit of the angle and azimuth is degree, and the ranges are:
# angle: [0, 360), azimuth: [-180, 180)
# Assuming that the input feature has a simple polygon geometry.
# i.e. non-aggregate, no holes, no arc-segments.
import math

def calculateAngleOfPolygonSegments(feature):
    angles, lengths, coords = [], [], feature.getAllCoordinates()
    for s, e in zip(coords[:-1], coords[1:]):
        dx, dy = e[0] - s[0], e[1] - s[1]
        a = math.degrees(math.atan2(dy, dx))
        angles.append(a if 0 <= a else 360 + a)
        lengths.append(math.hypot(dx, dy))
        
    azimuth = lambda t: (90 if t <= 270 else 450) - t
    for i, (a, b) in enumerate(zip([angles[-1]] + angles[:-1], angles)):
        feature.setAttribute('_vertex{%d}.acAngleIn' % i, a)
        feature.setAttribute('_vertex{%d}.acAngle' % i, b)
        feature.setAttribute('_vertex{%d}.acAzimuthIn' % i, azimuth(a))
        feature.setAttribute('_vertex{%d}.acAzimuth' % i, azimuth(b))
        feature.setAttribute('_vertex{%d}.length' % i, lengths[i])
Badge +3

Id objects (if they have none)

Topologybuilder or intersector and then

relate all lines by intersect criteria and calculate cardinalty = yes in group by mode Building_ID. Extract card_point > 0 . Calculate angle of related lines.

Segmentlengths can be grouped in a list.

Polyanalyser for doing this seems redundant.

Reply