Tuesday, 17 September 2019

qgis - How to consecutively number polygons from north to south following a polyline?


I have a shapefile (polygon) with a large number of polygons (roughly 10,000) that form a narrow but very long belt that windes through half a country and another shapefile (polyline) that represents the western border of the belt. Of those 10,000 polygons only about one third touches the border. So simply cutting the line into smaller lines using intersect, number those and then join back does not work. I need to gibe each polygon a unique ID-number that consecutively increases from the first polygon in the north to the last polygon in the south. My first idea, to simply create centroids, calculate the y-value for them and sort decreasingly, does not work either because the southern end is not the most southern point of the belt.


My question now is how to get this done with an automated action and without leaving the polygons behind that do not touch the border.


Edit:


Example




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...