2

I've got a small clipped extent of a LANDSAT image and I need to have the single pixels as polygons in order to tell the overlap proportions of overlaying polygons. In ArcGIS I used "Raster to polygon" without simplyfying polygons and used the "identity" tool then.

What would be a good equivalent in Grass GIS?

For "raster to polygon", I found "r.to.vect", but Grass always complains that the raster is "not properly thinned". I didn't understand what 'r.thin' does and I don't want ANY changes in the raster values. Can anybody help with a "clean" solution?

EDIT: According to Micha's answer, here's an illustration of what my final goal is: enter image description here

3
  • 3
    According to the docs thinning is for line features. Did you remember to select "area" as the feature type in r.to.vect? (I just did a test on a random raster and it didn't complain on either type, so I'm not certain about this.)
    – Rob Skelly
    Commented Aug 10, 2015 at 18:58
  • @RobSkelly is right, specify feature=area
    – webrian
    Commented Aug 11, 2015 at 2:35
  • That was the error! Beginner's mistake, sorry and thank you forthe answers!!!!!
    – countryman
    Commented Aug 11, 2015 at 5:45

3 Answers 3

3

According to the docs thinning is for line features. Remember to select "area" as the feature type in r.to.vect.

1

I think gdal_polygonize might help you. It will convert a raster to vector format (GML, shapefile, etc). By default it connects the cell that have same values, but from your description, it should not be a problem.

This text comes from the official site:

This utility creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. Each polygon is created with an attribute indicating the pixel value of that polygon. A raster mask may also be provided to determine which pixels are eligible for processing.

Below is a example converting a piece of raster to GML:

$ gdal_polygonize.py srtm_36_02.tif srtm_36_02.gml
Creating output srtm_36_02.shp of format GML.
0...10...20...30...40...50...60...70...80...90...100 - done.

[]

4
  • Okay, sounds nice, but how can I use this in Grass Gis?
    – countryman
    Commented Aug 10, 2015 at 16:34
  • You can run this command from your command line (Windows, Mac or Linux). See updated of my response. Commented Aug 10, 2015 at 18:30
  • Thank you very much! That's a useful alternative!!! (unfortunately I don't have enough reputation yet to upvote...)
    – countryman
    Commented Aug 11, 2015 at 5:46
  • No problem :) Glad it helped. Commented Aug 12, 2015 at 9:00
1

It seems that you final goal is to total raster values for each vector polygon. It's worth pointing out that the GRASS module v.rast.stats does just that.

1
  • Actually, it's the other way around...I want to know what the area contributions of the polygons to one LANDSAT pixel are. Maybe the little illustration in the edit helps
    – countryman
    Commented Aug 14, 2015 at 8:02

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.