Description Usage Source Examples
getsrtm
returns a RasterLayer object that points to a GeoTIFF file on disk containing the SRTM90 for Vietnam.
1 | getsrtm()
|
The CGIAR consortium (http://srtm.csi.cgiar.org).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | library(raster)
library(sp)
# getting the data:
srtm <- getsrtm()
srtm
filename(srtm)
projection(srtm)
# Ploting the elevation of Vietnam
plot(srtm)
# Ploting the elevation of Vietnam without legend and without axes:
plot(srtm, axes = FALSE, legend = FALSE)
# Plotting first the administrative limits of the country and then the elevations:
library(sf)
plot(st_geometry(gadmVN::gadm(level = "country")))
plot(srtm, axes = FALSE, legend = FALSE, add = TRUE)
# Cropping elevation inside one polygon:
hanoi <- subset(gadmVN::gadm(resolution = "high"), province == "Ha Noi")
hanoi_ele <- crop(srtm, hanoi)
plot(hanoi_ele)
plot(st_geometry(hanoi), add = TRUE)
# Removing anything that outside the polygon:
themask <- rasterize(hanoi, hanoi_ele)
hanoi_ele <- mask(hanoi_ele, themask)
plot(hanoi_ele)
plot(st_geometry(hanoi), add = TRUE)
# Extracting the elevation in 1 point:
extract(srtm, matrix(c(105, 21), 1))
# Extracting the elevations inside the province of Hanoi:
hanoi <- subset(gadmVN::gadm(resolution = "high"), province == "Ha Noi")
elevations <- extract(srtm, hanoi)
avg_ele_hanoi <- mean(unlist(elevations))
# Extracting the elevations in a buffer of 30 km of radius around Da Lat:
ele_dalat <- extract(srtm, matrix(c(108.459636, 11.938812), 1),
buffer = 30000)
mean(unlist(ele_dalat))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.