Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

R-Code to Map the Area Under the Curve From Reflectance Values Using Multispectral Satellite Image

You must read the multispectral image data into R, extract the reflectance values for a particular band, perform a calculation on each pixel and map the results, then save the map as a TIFF file.

Here is some code that demonstrates how to do this:

library(raster)
library(ggplot2)
library(ggmap)

# Load the TIFF image (Landsat or Sentinel or any other satellite image)
raster_image <- brick("YourMultispectral_image.tif")

# Extract a specific band
band_data <- extract(raster_image, 1)

# Create a wavelength vector
wavelength_vector <- seq(400, 700, by = 10)

# Define the reflectance function
# The reflectance function uses the approx function to interpolate the reflectance values at the desired wavelength values 
reflectance_function <- function(x) {
  y <- approx(wavelength_vector, x, xout = x)$y
  return(y)
}

# Calculate the area under the curve for each pixel
results <- calc(band_data, fun = function(x) {
  integrate(reflectance_function, min(wavelength_vector), max(wavelength_vector), x = x)$value
})

# Plot the results on a spatial map
# The extent of the raster image is used to define the location of the map, and the zoom level is set to 10
ggmap(get_map(location = extent(raster_image), zoom = 10)) +
  geom_raster(data = as.data.frame(results),
              aes(x = x, y = y, fill = layer)) +
  scale_fill_gradient(low = "blue", high = "red") +
  ggtitle("Spatial Map of Area under the Curve of Reflectance Values") +
  xlab("Longitude") +
  ylab("Latitude")

# Save the result as a TIFF file
writeRaster(results, filename = "area_under_the_curve_map.tif", format = "GTiff", overwrite = TRUE)

Leave a Reply

Your email address will not be published. Required fields are marked *

13 + ten =

This site uses Akismet to reduce spam. Learn how your comment data is processed.