Using Satellite Images

Usando Imágenes Satelitales

Author

Martin Olmos

Published

March 19, 2022

Brief concept intro1

Satellite remote sensing or satellite remote sensing is the activity of collecting data through the use of sensors, in this case satellites, from a place to which there is no physical access, that is, remotely.

These data consist of the measurement of electromagnetic energy. Electromagnetic radiation is a form of energy emitted by all matter with a temperature above absolute zero (0 Kelvin or -272° Celcius). X-rays, ultraviolet, visible light, infrared, heat, microwaves, and radio and television waves are all forms of electromagnetic energy with different wavelengths or frequencies and are part of the electromagnetic spectrum.

Hotter objects emit more electromagnetic energy and shorter wavelengths than cooler ones. The most common source of electromagnetic radiation is the Sun. Objects that make up the Earth’s surface reflect and emit electromagnetic radiation in different ways.

The portion of the electromagnetic spectrum where the peak of solar radiation is located is called the visible band, since human vision is sensitive to these waves. Remote sensing allows us to extend the human ability to perceive electromagnetic radiation beyond the visual band, so the parts of the electromagnetic spectrum that we cannot see are very important.

The objects that make up the Earth’s surface reflect electromagnetic radiation in different ways. The appeal of multispectral remote sensing is that objects indistinguishable at one wavelength may be easy to distinguish at another. The bands commonly used to perceive occupation and land use are: visible, infrared and microwave.

Understanding the different ways in which specific wavelengths interact with different objects allows finding “stamps” or “signatures” that will allow those objects to be detected automatically.

The applications are diverse: monitoring of deforestation, soil degradation, detection and classification of objects as dissimilar as wetlands, informal settlements and gated communities, monitoring of water quality and salinity, air quality, detection of clandestine dumps, monitoring of landfills health, monitoring the environmental impact of certain industries, among others.

In this post I am not going to advance in detection or classification of objects but, following this tutorial I am going to use satellite images together with SRTM elevation data to make a 3D map of my favorite place in the world: the Cuesta del Viento Dam in Rodeo, San Juan.

Here is the code:

library(rayshader)
library(sp)
library(raster)
library(scales)

rodeo_elevation <- raster::raster("S31W070.hgt")

height_shade(raster_to_matrix(rodeo_elevation)) %>% 
  plot_map()

rodeo_r <- raster::raster("LC08_L1TP_232081_20210817_20210826_01_T1_B4.TIF")
rodeo_g <- raster::raster("LC08_L1TP_232081_20210817_20210826_01_T1_B3.TIF")
rodeo_b <- raster::raster("LC08_L1TP_232081_20210817_20210826_01_T1_B2.TIF")

rodeo_rgb <- raster::stack(rodeo_r, rodeo_g, rodeo_b)

raster::plotRGB(rodeo_rgb, scale=255^2)

rodeo_rgb_corrected <- sqrt(raster::stack(rodeo_r, rodeo_g, rodeo_b))
raster::plotRGB(rodeo_rgb_corrected)

raster::crs(rodeo_r)
raster::crs(rodeo_elevation)

rodeo_elevation_utm <- raster::projectRaster(rodeo_elevation, 
                                             crs = crs(rodeo_r), 
                                             method = "bilinear")

crs(rodeo_elevation_utm)

bottom_left <- c(y=-69.1478, x=-30.2374)
top_right <- c(y=-69.0077, x=-30.1295)

extent_latlong = sp::SpatialPoints(rbind(bottom_left, top_right), 
                                   proj4string=sp::CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))
extent_utm <- sp::spTransform(extent_latlong, raster::crs(rodeo_elevation_utm))

e <- raster::extent(extent_utm)

rodeo_rgb_cropped <- raster::crop(rodeo_rgb_corrected, e)
rodeo_elevation_cropped <- raster::crop(rodeo_elevation_utm, e)

names(rodeo_rgb_cropped) <- c("r", "g", "b")

rodeo_r_cropped = rayshader::raster_to_matrix(rodeo_rgb_cropped$r)
rodeo_g_cropped = rayshader::raster_to_matrix(rodeo_rgb_cropped$g)
rodeo_b_cropped = rayshader::raster_to_matrix(rodeo_rgb_cropped$b)

rodeo_elevation_matrix <- rayshader::raster_to_matrix(rodeo_elevation_cropped)

rodeo_rgb_array <- array(0, dim = c(nrow(rodeo_r_cropped), ncol(rodeo_r_cropped), 3))

rodeo_rgb_array[,,1] <- rodeo_r_cropped/255
rodeo_rgb_array[,,2] <- rodeo_g_cropped/255
rodeo_rgb_array[,,3] <- rodeo_b_cropped/255

rodeo_rgb_array <- aperm(rodeo_rgb_array, c(2,1,3))

plot_map(rodeo_rgb_array)

rodeo_rgb_contrast <- scales::rescale(rodeo_rgb_array, to=c(0,1))

plot_map(rodeo_rgb_contrast)

plot_3d(hillshade = rodeo_rgb_contrast, 
        heightmap = rodeo_elevation_matrix,
        windowsize = c(1100, 900),
        zscale = 15, 
        shadowdepth = -50, 
        zoom = 0.5,
        phi = 45, 
        theta = -45, 
        fov = 70, 
        background = "#F2E1D0", 
        shadowcolor = "#523E2B")

render_snapshot(title_text = "Dique Cuesta del Viento, San Juan | Imagery: Landsat 8 | DEM: 30m SRTM", 
                title_bar_color = "#523E2B", title_color = "white", title_bar_alpha = 1)

# Video

angles <- seq(0, 360, length.out = 1441)[-1]

for(i in 1:1440) {
  render_camera(theta = -45+angles[i])
  render_snapshot(filename = sprintf("cuesta_%i.png", i),
                  title_text = "Dique Cuesta del Viento, San Juan | Imagery: Landsat 8 | DEM: 30m SRTM",
                  title_bar_color = "#1f5214", title_color = "white", title_bar_alpha = 1)
}

rgl::rgl.close()

And the resulting visualization:

Footnotes

  1. En base al MOOC “Imagery, Automation, and Applications” de la Universidad de California, Davis y al libro de David DiBiase, The Nature of Geographic Information. Penn State University, College of Earth and Mineral Sciences. Retrieved from https://www.e-education.psu.edu/natureofgeoinfo/↩︎