2

I'm using QGIS and I have polygons such as this

this.

I would like to generate a feature table with the point in each polygon, and a sort of 'encoding' of the corresponding polygon.

I would like to represent each of the polygons as a feature using their shape complexities. I read a paper which uses an approach they referred to as 'vertex coding' and described as 'a chain coding approach to encode the shape of the building plan outline as a sequence of segment lengths, where each segment, or wall, denotes a significant change of direction.' This means the vertex code for a single polygon with 5 sides could be l1-l2-l3-l4-l5 where l1:l5 are the lengths of each side of the polygon.

I had found a Plugin "PolygonComplexity", but it is written for an older version of QGIS.

Taras
  • 32,823
  • 4
  • 66
  • 137
  • Its very common for land parcel/cadastre boundaries to be captured originally in this manner (basically like a survey). Each line segment would have a length and bearing. This info is already available as part of the geometry of the polygon in QGIS, so should be able to be derived somehow. .....Im not sure i understand why this information would need to be stored as an encoding in a point geometry? Could you elaborate on this requirement? – nr_aus Aug 31 '20 at 02:45
  • 1
    Have you had a look at WKT? – Erik Aug 31 '20 at 06:44
  • Seems to be a couple of separate issues here: first you need to define what this representation looks like, then secondly how to implement that into QGIS. I don't think we can help with the first one without a good understanding of the purpose. Want to focus the question on that only? – Spacedman Aug 31 '20 at 07:33
  • Can you link to the paper on "vertex coding"? – Spacedman Aug 31 '20 at 07:33
  • here's the paper. I would like to add the shape complexity feature to a much larger data set to carry out classification analysis on the buildings. – Olohime Umakhihe Aug 31 '20 at 14:28

2 Answers2

3

The most indirect but most highly appreciated solution is a Plugin's Python version conversion, i.e. from Python 2 into Python 3. This approach is described in these articles GIS for Thought | Updating A Plugin From QGIS 2 to QGIS 3 and QGIS GitHub | Plugin migration to QGIS 3.

Albeit, probably the most feasible solution can be achieved by means of Expressions in the Field Calculator in QGIS.

Let's assume there is a polygon layer "grid" with its attribute table accordingly, see image below.

example

So, calculating required parameters can be achieved using the following formulas

CS    | $perimeter / (3.45 * area($geometry))
CP    | 0.8 * "AP" * "FQ" * (0.2 * "CV")
CV    | (area(convex_hull($geometry)) - area($geometry)) / area(convex_hull($geometry))
AP    | (perimeter($geometry) - perimeter(convex_hull($geometry))) / perimeter($geometry)
FQ    | 16 * ("notch" / ("vert" - 3) - 0.5)^4 - 8*("notch" / ("vert" - 3) - 0.5)^2 + 1
vert  | num_points($geometry)
notch | array_length(array_filter(array_foreach(generate_series(0, num_points(geometry($currentfeature))-1), angle_at_vertex($geometry, @element)), @element > 180))

So, the resulting attribute table may be looking as following

resulting_AT

If in the end you need points (geocentroids) instead of polygons, then apply one more algorithm via Vector > Geometry Tools > Centroid.


References:

Taras
  • 32,823
  • 4
  • 66
  • 137
  • 1
    @Romarinho Please stop making Answer edits. Offer your own Answer if you disagree with the Answer, instead of making revisions to the 3+ year old accepted answer – Vince Jan 25 '24 at 12:46
0

If you can do it knowing the equations, using the expressions you can calculate it and assign it to a field in the table of attributes.

As I see it requires geometric properties like area, perimeter, number of vertices.

As for the line segments, which form the polygon, you can get them, calculate their length, angles using expressions. Specifically, in the geometry tab then segments_to_line

Luis Perez
  • 1,284
  • 4
  • 11