How to mask the images in GRASS?

How to mask the images in GRASS

  • I have MODIS NDVI images, which needs to be masked with VI_Quality. I am using GRASS software and executing GRASS commands using shell scripts. I need to perform raster calculation (multiplication) for NDVI images with the VI_Quality. I want to multiply ith NDVI image with the ith image of VI_Quality. I have used the following codes : for file in $NDVIFILES; do r.mapcalc "$file = $NDVIFILES * $QAFILES; done i=1 for file in $NDVIFILES; do r.mapcalc "file $((i++)) = NDVIFILES $((i++)) * QAFILES $((i++))"; done I am unable to do this raster multiplication in a loop. Please let me know the correct syntax to do this operation. Thanks

  • Answer:

    Here's what I suggest: g.mlist --q type=rast pattern-"*NDVI" mapset=shenkottah >> NDVIFILES and a similar expression for the QAFILES This will leave you with two files on your disk, each containing a list of the raster map names. To verify, test with the sed expression: sed -n "4p" NDVIFILES Then you should be able to run a loop to read the raster names and do your mapcalc, something like: for i in `seq 1 22`; do \ NDVI=`sed -n "${i}p" NDVIFILES`; QA=`sed -n "${i}p" QAFILES`; r.mapcalc new_${i} = $NDVI * $QA; done

Karthik K at Geographic Information Systems Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.