1

I am working with a raster file that represents the percentage of vineyards by commune (e.g., municipality) in a region in France. The statistics were calculated for each commune based on surveys from the ministry of agriculture. My problem is that the statistics and the resulting raster were elaborated by a colleague and our boundaries for different communes do not match. In other words, some cells which have the label for one commune according to my commune polygon vector (and rasterized afterwards) have the label of other commune in according to his map. I though I could create a new raster in which a unique value is given for each commune using the command r.mode.

The most frequent value within each polygon could be extended to all the commune area.

I am using GRASS GIS. My problem is that the raster file has float values and r.mode requires integer values.I need to transform my float values into integers, but before I need to multiply my values by 1000000 or similar since all my raster values are smaller than 0.

I would like to do it in r.mapcalc, using an expression like:

r.mapcalc value_int@covariates = int(value@covariates * 1000000)

but this expresion gives me an error.

I may not have a lot of imagination, so if any solution can be done in R, I would also be really thankful.

  • 1
    Not sure but maybe this post might help? – Joseph Jan 12 '15 at 15:11
  • 1
    The mode rarely makes sense for floating point rasters. If you think it does, then you are likely thinking that the raster values are densities and you should be seeking the location(s) where those values are greatest. Please consider editing this question to include information about what your raster represents and what you hope the mode will tell you about the polygon regions. – whuber Jan 12 '15 at 15:44
1

again, I found the answer somewhere else:

http://lists.osgeo.org/pipermail/grass-user/2010-October/058381.html

"The base map should be integer (category ) values, where the mode is calculated for all cells with the same cat value, so it indeed should be an integer raster."

I need to transform my float values into integers, but before I need to multiply my values by 1000000 or similar since all my raster values are smaller than 0.

I would like to do it in r.mapcalc, using an expression like:

r.mapcalc value_int@covariates = int(value@covariates *1000000) but it gives me an error.

  • what error?? Can r.mapcalc write rasters to different mapsets? I would guess you can't have the @ on the LHS. – mankoff Mar 4 '18 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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