4

I have a global land cover raster that I would like to convert into a shapefile. Rather than converting the entire raster I would like to "extract" just the forest value (40 in this case) and then convert that to a polygon. I haven't worked with Rasters much before so haven't been able to work out a solution. I'm using QGIS.

7
  • Why not convert all codes then delete everything but 40 from the shapefile? Is the shapefile too large with all the codes? Commented Mar 27, 2017 at 1:28
  • That is what I'm wondering. I have been running the polygonize for over an hour now and nothing is returned. The original tiff is 400MB so not sure how long this would take as it is a global map. If the polygonize works then I would be happy to use this approach but I'm not sure if it will.
    – James
    Commented Mar 27, 2017 at 1:32
  • 1
    On a global scale? I wouldn't. The maximum size for a shapefile is 2GB support.esri.com/technical-article/000010813 for any component, this is due to 32 bit addressing not just Esri software. You will need to create tiles but should also extract just the code you're after, try the instructions gis.stackexchange.com/questions/49800/… and see how that goes or you can use gdal_calc gdal.org/gdal_calc.html (3rd example, --calc="A*(A==40)") Commented Mar 27, 2017 at 1:47
  • This is fantastic, thank you very much for your help, this is the answer I needed.
    – James
    Commented Mar 27, 2017 at 1:50
  • @MichaelMiles-Stimson I tried the option in gis.stackexchange.com/questions/49800/… and it returns a 30GB "empty" tif. I'm using the expression "GLOBCOVER_L4_200901_200912_V2.3.color@1" = 40. I get the "40" by using the identify feature tool and clicking on the color that I'm trying to extract. 40 is the number that corresponds to the Value. Any idea what I'm doing wrong?
    – James
    Commented Mar 27, 2017 at 13:53

1 Answer 1

5

If you have SAGA installed under QGIS, you can use Victorising grid classes tool located in Processing Toolbox -> SAGA -> Shapes - Grid -> Victorising grid classes. As you can see in the image below, you need to change the Class Selection from All Classes to One single class specified by the class identifier, Then Choose the class pixel value (in your case 40). You can set the polygon class as Multipolygon or single polygon, then save the output file.

enter image description here

Here is a sample land use

enter image description here After victorising one class:

enter image description here

Please note for global land use/cover, it may take long time to convert from raster to vector.

1
  • @ahmadhand thanks for the suggestion. I would love to us this approach but am getting an error message that appears to be connected with this version of SAGA on a Mac. Hopefully it will be fixed on the next update.
    – James
    Commented Mar 27, 2017 at 13:55

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.