Section 6 Getting spatial data
6.1 Load libraries
This section looks at using Google Earth Engine (Gorelick et al. 2017) to retrieve remote sensing data and process it for use. This code is in Javascript. The cropped raster can be saved to your Google Drive. Retrieval of the raster from Drive is not covered. The data are much too large to be rendered here, and their inspection is also not covered.
6.2 Getting temperature data
Code to get 30m thermal data from LANDSAT-5 (Schmidt et al. 2013).
// get extent and landsat 5 data
var geometry = /* color: #ff3d3d */ee.Geometry.Polygon(
[[[77.26686452041235, 13.344492655458648],
[77.26803063514615, 12.69020162411501],
[78.31220864869454, 12.698000169170149],
[78.31998125667042, 13.342950249131635]]]),
table = ee.FeatureCollection("users/pratik_unterwegs/ele_ext"),
table2 = ee.FeatureCollection("users/pratik_unterwegs/kruger_clip"),
l5 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR");
//define func
var crop = function(x){
var image = x.
clip(table).
divide(10).
subtract(273);
return image;
}
// filter landsat 5 data for time, cloud cover, and thermal band
var filtered = l5.filterDate('2007-08-01', '2009-08-30').
filterMetadata('CLOUD_COVER', 'less_than', 10).
select('B6').
map(crop).
mean();
var rgb_viz = {min: 20, max: 35, bands:['B6'],
palette: ["#0D0887FF", "#4C02A1FF", "#7E03A8FF", "#A92395FF", "#CC4678FF", "#E56B5DFF","#F89441FF", "#FDC328FF", "#F0F921FF"]
};
Map.addLayer(filtered, rgb_viz, 'kruger_temp');
// export to google drive
Export.image.toDrive({
image: filtered,
description: 'kruger_temperature',
scale: 30,
region: table.geometry()});
6.3 Getting elevation data
Code to get 30m elevation data from SRTM (Farr et al. 2007) using the Google Earth Engine Javascript API. This data was acquired and later not used.
//load SRTM data and elephant extent
var image = ee.Image("USGS/SRTMGL1_003"),
table = ee.FeatureCollection("users/pratik_unterwegs/ele_ext"),
ext = ee.FeatureCollection("users/pratik_unterwegs/ele_ext"),
geometry = ee.Geometry.MultiPoint();
//filter 30m DEM for the polygon
var srtm_clip = image.clip(ext.geometry());
Map.addLayer(table);
//get slope
var srtm_slope = ee.Terrain.slope(srtm_clip);
//check elevation map
Map.addLayer(srtm_clip, {min: 0, max :500, palette: ["#00A600FF", "#2DB600FF", "#63C600FF", "#A0D600FF", "#E6E600FF", "#E8C32EFF",
"#EBB25EFF", "#EDB48EFF", "#F0C9C0FF", "#F2F2F2FF"
]}, 'elevation');
// check slope map
Map.addLayer(srtm_slope, {min: 0, max :10, palette: ["#00A600FF", "#2DB600FF", "#63C600FF", "#A0D600FF", "#E6E600FF", "#E8C32EFF",
"#EBB25EFF", "#EDB48EFF", "#F0C9C0FF", "#F2F2F2FF"
]}, 'slope');
//export to file
Export.image.toDrive({
image: srtm_clip,
description: 'kruger_elevation',
scale: 30,
region: table.geometry()
});
Export.image.toDrive({
image: srtm_slope,
description: 'kruger_slope',
scale: 30,
region: table.geometry()
});
6.4 Reproject data to UTM 36S
# use gdalwarp from gdalutils
library(gdalUtils)
library(stringr)
library(glue)
# list the files and warp them
kruger_rasters = list.files("data",
pattern = "tif",
full.names = TRUE,
include.dirs = FALSE)
map(kruger_rasters, function(df){
name = str_split(df, ".tif", simplify = TRUE)[,1]
gdalwarp(srcfile = df,
dstfile = as.character(glue('{name}_UTM.tif')),
t_srs = "+proj=utm +zone=36 +south +datum=WGS84 +units=m +no_defs",
tr = c(30,30))
})
References
Farr, Tom G., Paul A. Rosen, Edward Caro, Robert Crippen, Riley Duren, Scott Hensley, Michael Kobrick, et al. 2007. “The Shuttle Radar Topography Mission.” Reviews of Geophysics 45 (2). https://doi.org/10.1029/2005RG000183.
Gorelick, Noel, Matt Hancher, Mike Dixon, Simon Ilyushchenko, David Thau, and Rebecca Moore. 2017. “Google Earth Engine: Planetary-Scale Geospatial Analysis for Everyone.” Remote Sensing of Environment 202: 18–27. https://doi.org/10.1016/j.rse.2017.06.031.
Schmidt, Gail, Calli B. Jenkerson, Jeffrey Masek, Eric Vermote, and Feng Gao. 2013. “Landsat Ecosystem Disturbance Adaptive Processing System (LEDAPS) Algorithm Description.” USGS Numbered Series 2013-1057. Open-File Report. Reston, VA: U.S. Geological Survey. http://pubs.er.usgs.gov/publication/ofr20131057.