5

I need to vectorize the cell boundaries of a raster map and I have forgotten how to do this.

For instance, if I have a raster map of a region that is just map=1 with a cell size of 500m, I would get a map that shows a grid that is 500m on each side.

2 Answers 2

3

You can simply make a vector grid with 500m starting at the same coordinate of the raster file. With QGIS you can do this with vector tools -> vector grid. enter image description here

2
  • Exactly what I was going to say! Jan 5, 2012 at 18:44
  • This is easier and for the English speakers, this would be the command v.mkgrid
    – Don
    Jan 6, 2012 at 1:56
2

Not the most elegant solution but here is what I did.

1) My raster map in question was actually a MASK where all the cells where all the cells were=1. So I just set my region to the are I wanted my cells outputted and ran

     r.mapcalc myMaskRand = rand(1,1000)

2) Then I just converted that map to vector using

     r.to.vect input=myMaskRand output=myMaskRandV feature=area

3) Then a bit of v.clean and I was good to go.

The only problem is that there were a couple of times that the resulting raster map had duplicate cell values and those cells were lumped. I suppose the best way of ensuring this not happening would be to run

     r.mapcalc myMaskRand = rand(1,1000)*rand(7,77)

or something equivalent.

1
  • That's a good solution. You can expect to have some neighboring cells with the same value, though. A more reliable (and elegant) way is to compute a "checkerboard" pattern of nine alternating values. E.g., one row goes 0120120..., the next goes 3453453..., the next 6786786..., and then you repeat. This is readily done in any raster GIS that supports modular arithmetic and will let you generate grids of row indexes and column indexes: it equals 3*([row] mod 3) + ([col] mod 3).
    – whuber
    Jan 6, 2012 at 14:36

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.