3

I'm stuck with a problem:

I got three raster's layers: "Sand", "Clay" and "BD" (Bulk density) of the same region.

How can I obtain a "table" or a "Data frame" with information for the values of the raster's for each pixel?

I prefer to use QGIS or R.

My main goal is to obtain a lookuptable of this features of the soil:

enter image description here

So i will merge pixels with the same information for Clay, Sand and BD into a unique MU_GLOBAL index.

2

2 Answers 2

3

Do you need to calculate the values of the entire extent of the raster?

if so in QGIS is very easy and fast, you can use expressions and get the global statistics of your raster in a table.

  1. Create a temporary layer, not geometry. Or create a dbf table
  2. In the toolbar there is a button that allows you to add a record.
  3. Open the field calculator, then go to the expressions in the raster option, you will find two options: statistics and value.

We will use the statistics, you can calculate the value:

  • max: maximum
  • min: minimum
  • avg: average
  • stdev: standard deviation
  • range: range
  • sum: sum

An example calculating the average, give a name to the field, define a decimal number, with two or more decimals.

  1. Write and execute the expression:

raster_statistic('BASIN001D8',1,'avg')

In this case, 'CUENCA001D8' is the name of the layer as it appears in the layers panel. The value 1 is the band of the raster layer being queried.

3

Using R, you could do something like:

# Assuming the raster layers are geotiff format
library(raster)
rast_list = c(""Sand.tif", "Clay.tif", "BD.tif")
soil_stack = stack(rast_list)
soil_values_df = values(soil_stack)

Although, depending on the size of your region, and resolution, this could be quite inefficient. Not sure what MU_GLOBAL refers to.

1
  • Hey Micha! MU_GLOBAL refers to equal combinations between sand, clay and bd! Commented May 29, 2021 at 16:51

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.