1

I have a raster of the entire united states with 30 meter by 30 meter pixel size. Each pixel has a value of either 0 or 1, with 1 defining a certain type of landcover.

I need to find the percent of 1's within 1 km by 1 km areas gridded across the entire raster so that I know for each 1 sq km, what percent of it is the landcover I'm interested in.

Despite a lot of googling, I am unsure about how to proceed. Mostly how to create the grid. It looks like once I have that I could use v.rast.stats in GRASS. But maybe I'm way off.

As a result, I don't have a specific error I'm encountering, but rather do not understand the tools well enough to know how to proceed to get my desired output.

2

Since you mentioned GRASS in the question (although not in the tags), i can suggest an easy procedure. Your 30x30 raster is binary, so summing all pixels in a 1kmx1km grid will give you the number of desired landcover pixels in the coarse grid. You can do this by resampling in GRASS. If you then do

(sum/(33.3X33.3))*100

divide by the total number of original pixels in each coarse grid pixel and multiply by 100, you'll have the percent.

Here's the code in GRASS: (assume your binary raster is called lc30, and you are using a projected CRS)

# First Set computation region to 30 meter landcover raster
g.region -ap rast=lc30
# reset the resolution to the coarse 1km resolution
g.region res=1000
# Resample to the coarse grid, using "sum"
r.resamp.stats input=lc30 output=lc1km method=sum
# and calculate a new map with percentage 
r.mapcalc "lc1km_pcent = (lc1km / (33.3*33.3)) * 100.0"
  • Thanks. I only have experience with GRASS insofar as what is included in QGIS. It doesn't appear to have a g.region module, however I am looking into how I can add it. – jzadra 2 days ago
  • I warmly recommend working with GRASS independent of QGIS first, to learn the concepts and modules. Then, after understanding what you need to do, you can more easily run the QGIS wrapper procedures. – Micha yesterday
  • Sadly my deadline is just about up, so I'm afraid I won't be able to spend the time to learn GRASS. But thank you for your help! – jzadra yesterday

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.