forked from geocompx/geocompr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
08-raster.Rmd
46 lines (41 loc) · 1.32 KB
/
08-raster.Rmd
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
44
45
46
# Working with raster data {#raster}
## Prerequisites {-}
<!--
- nrow, ncol, nlayers, dim, ncell, res, extent, crs
- crop, mask, merge
- aggregate, disaggregate, resample
- projectRaster
- reclass, cut
- focal, focalStack, focalNA, zonal
- overlay, calc
- area, distance
- clump
- mosaic
- cellStats
- stackApply
- getValues
- terrain, hillshade ?
-->
<!-- # https://aws.amazon.com/public-data-sets/landsat/ -->
<!-- ## other stuff -->
<!-- # http://grindgis.com/blog/vegetation-indices-arcgis -->
<!-- ## calculate ndvi from red (band 1) and near-infrared (band 2) channel -->
<!-- # Band 4 reflectance= (2.0000E-05 * (“sub_tif_Band_4”)) + -0.100000 -->
<!-- process_landsat8_ndvi <- function(input, type){ -->
<!-- DN_to_radiance <- function(value){ -->
<!-- value*2.0000E-05-0.1 -->
<!-- } -->
<!-- r4 <- DN_to_radiance(input) -->
<!-- if (type == 1){ -->
<!-- ndvi <- overlay(r4[[1]], r4[[2]], fun = function(x, y) { -->
<!-- (y-x) / (y+x) -->
<!-- }) -->
<!-- writeRaster(ndvi, 'data/landsat8_ndvi_spk.tif', overwrite=TRUE) -->
<!-- } else if (type == 2){ -->
<!-- savi <- overlay(r4[[1]], r4[[2]] ,fun = function(x, y) { -->
<!-- l=0.5 -->
<!-- ((y-x) / (y+x+l)) * (1+l) -->
<!-- }) -->
<!-- writeRaster(savi, 'data/landsat8_savi_spk.tif', overwrite=TRUE) -->
<!-- } -->
<!-- } -->