In QGIS is there a way to assign ascending numbers (attribute) to polygons that are located in a row. The polygons were not created in sequential order.

enter image description here

  • 1
    I don't think there's a tool to do it. The approach would be to build the adjacency graph of the polygons then starting from one end compute the distance to all the other nodes in the graph. I can't find a plugin to compute the adjacency network as a line coverage (although I think my old topocolor plugin did it) which would be the first step. Requires some python coding. Check the "Map Colouring" plugin's code for ideas on computing adjacency graphs...
    – Spacedman
    Jul 7 '16 at 15:53
  • If the data was in PostgreSQL, then you could use this solution
    – Vince
    Jul 8 '16 at 0:25
  • @Vince that might work assuming the connected polygons are aligned east-west. The map image above looks like a row of plots on a street, which could be going in any direction, or even on a curve. Dion, Is that true? Are you trying to number plots on a street?
    – Spacedman
    Jul 8 '16 at 6:47
  • @Spacedman yes that is correct. I am trying to assign numbers to plots on a street. Would it help if I generated polygon centroids, connect the points with a line and then determine the sequence of the points along the line?
    – Dion
    Jul 8 '16 at 8:46
  • @Dion that's sort of what I mean about building an adjacency graph. You'd still need some python code to "walk the line" and work out the corresponding numbers.
    – Spacedman
    Jul 8 '16 at 10:38

Once you have the polygon centroids you could get the coordinates of the centroid and then sort them (e.g. by west to east coordinate) to get the correct order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.