1

Does anyone know of a method to split vector data based on a corresponding raster layer.

For example, I have a classification with two classes and have an overlaid vector layer as seen in the image below. The classification has identified 2 classes in one of the polygons.

enter image description here

What I'm trying to do is split the polygon based on the detected split in the classification.

enter image description here

I've looked into polygonising the classification but when implementing this on a large scale this would talk a huge amount of time which I'm trying to avoid. I've also looked into clustering but couldn't seem to get any good of it.

By any chance has anyone else looked into something similar?

2
  • 2
    Which software are you working with?
    – Erik
    Commented Apr 27, 2021 at 11:36
  • QGIS normally but I'm happy to try it on anything!
    – Mícheál
    Commented Apr 27, 2021 at 12:03

1 Answer 1

1

Run Zonal Statistics As Table (or the QGIS equivalent) on your vector layer to get the min and max per polygon. Select polygons where min is not equal to the max (i.e. these polygons cover multiple raster values). Clip the raster based on these polygons, and then polygonize this clipped raster. Merge the resulting polygons back with the original polygons which only covered one raster value (this might mean you need to split the original polygon layer in two - single pixel value and multiple pixel values).

Things to keep in mind:

  • The above process is a bit clunky. If most of your polygons overlap multiple raster values you're probably better off just polygonizing the raster right from the beginning.
  • If you're thinking of using this as a way to regularly update the polygon boundaries you want to think about if their is a way to apply some kind of flag field (flag = raster likely changed here) to the polygons in advance so that you could skip the Zonal Stats step and just select polygons based on the flag.
2
  • It might be clunky, but it still works!! Thanks a million for the help @ycartwhelen! Yea, the plan is to use it more as a flag system than an automated approach. Honestly, with a bit of cleaning on the classification, the method you laid out pretty much does the job! Thanks again!
    – Mícheál
    Commented Apr 27, 2021 at 13:14
  • Great to hear that! Putting the code into a script might make it smoother to run if it's going to be something reused multiple times. Commented Apr 27, 2021 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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