TransWikia.com

Changing the order of the polygon's nodes using the geometry generator in QGIS

Geographic Information Systems Asked by Ilton on July 20, 2021

enter image description here

How can I, using the geometry generator, change the order of the polygon’s nodes, starting from the most northerly node in QGIS?

One Answer

I've made a recipe. In fact, I do not really exactly answer the question as I do not change order of your polygon(s) nodes but simply try to solve the issue of changing numbering of nodes according to your screenshot.

The recipe calculates the position of the northern vertex of your polygon and then use it to change numbers ordering. It avoids reconstructing the geometry by changing position of each point, just change numbering. I suppose there are way for improvements or you may encounter bugs as I did not tested extensively. Moreover, you may add more complex instructions to choose between points with same y max coordinates.

Replace in Font Marker Character(s) expression

@geometry_part_num

with

with_variable('new_position',
  with_variable('n_to_p', nodes_to_points(force_rhr($geometry)),
    with_variable('array_coord_y', array_foreach(
        generate_series(1, num_points(@n_to_p)), y(point_n(@n_to_p, @element))
      ),
      array_find(@array_coord_y, array_first(
          array_sort(
            @array_coord_y, ascending:=false
          )
        )
      )
    )
  ),
  if (
    @geometry_part_num <= @new_position,
    num_points($geometry) - 1 + @geometry_part_num - @new_position,
    @geometry_part_num - (@new_position)
  )
)

Answered by ThomasG77 on July 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP