0

I need a solution for that case:

I have got a fishnet-raster (as polygons) without any systematic order in the ID of the features and need to label every rectangle from A1 to F6:

enter image description here

For now I do it manually but I have 150 of them.

I'm looking for a way using QGIS, Python or PostGIS to automatically assign a name or a number to my grid-rectangles.

MartinMap
  • 8,262
  • 7
  • 50
  • 114
  • 1
    The answer to all "Is it possible" questions is usually "Yes." Please choose one software solution and edit your question to focus on that. "This or that" questions are effectively two questions, which violates the "One question per Question" policy. There is already an answered question on sequential labeling in PostgreSQL, but you have more information available (regular polygon alignment) so it should be pretty easy to code. You should include the exact software release and a best coding effort in your question. – Vince Sep 15 '17 at 10:29
  • Related: https://gis.stackexchange.com/questions/73978/numbering-polygons-according-to-their-spatial-relationships – Vince Sep 15 '17 at 10:37
  • This is a follow up to this question, no? The reason I didn't include this in the original answer was because you wanted a one to one relationship in the output table between the generated fishnet for each box and the box name, which means using a MultiPolygon for each fishnet. If you dropped that restriction, it would be easy to rewrite the fishnet code to return the x and y, or A1-F6 for each returned square within each 6x6 geom returned by fishnet. – John Powell Sep 15 '17 at 11:33
  • Failing that, you could use ST_Dump on the multipolygons, and two generate_series loops to generate the A1...F6 sequence. The solution is easy enough, but I want to be sure I am answering the right question. – John Powell Sep 15 '17 at 11:34
  • 1
    I've written a plugin to do this already, see this answer - which also suggests an alternative for cases where the plugin isn't suitable – Steven Kay Sep 15 '17 at 12:07
  • 1
    @StevenKay, that's very nice, but it is probably easier if I fix the Postgis function from the OP's original question, seeing as it is already producing the grids that this question relates to. However, need clarification on approach. – John Powell Sep 15 '17 at 15:04

0 Answers0