rm(list=ls())
library(raster)
## Loading required package: sp
dem <- raster(ncol=3, nrow=3, xmn=100, xmx=115, ymn=100, ymx=115)
ncell(dem)
## [1] 9
res(dem)
## [1] 5 5
valores <- c(50, 45, 50, 30, 30, 30, 8, 10, 10)
(values(dem) <- valores)
## [1] 50 45 50 30 30 30 8 10 10
plot(dem, main = "DEM")
text(dem)
###asignar un sistema de coordenadas de referencia al DEM
crs(dem) <- CRS('+init=epsg:3115')
(slope = terrain(dem, 'slope', unit='degrees', neighbors=8))
## class : RasterLayer
## dimensions : 3, 3, 9 (nrow, ncol, ncell)
## resolution : 5, 5 (x, y)
## extent : 100, 115, 100, 115 (xmin, xmax, ymin, ymax)
## crs : +init=epsg:3115 +proj=tmerc +lat_0=4.596200416666666 +lon_0=-77.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
## source : memory
## names : slope
## values : 75.25766, 75.25766 (min, max)
plot(slope, main = "Pendiente")
text(slope)
(aspecto = terrain(dem, 'aspect', unit='degrees', neighbors=8))
## class : RasterLayer
## dimensions : 3, 3, 9 (nrow, ncol, ncell)
## resolution : 5, 5 (x, y)
## extent : 100, 115, 100, 115 (xmin, xmax, ymin, ymax)
## crs : +init=epsg:3115 +proj=tmerc +lat_0=4.596200416666666 +lon_0=-77.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
## source : memory
## names : aspect
## values : 180.7538, 180.7538 (min, max)
plot(aspecto, main = "Aspecto")
text(aspecto)
rm(list=ls())
library(raster)
dem <- raster(ncol=4, nrow=4, xmn=98, xmx=120, ymn=98, ymx=120)
ncell(dem)
## [1] 16
res(dem)
## [1] 5.5 5.5
valores <- c(50, 45, 50,48, 30, 29, 30,29,10,9,9,10,25,23,19,21)
(values(dem) <- valores)
## [1] 50 45 50 48 30 29 30 29 10 9 9 10 25 23 19 21
plot(dem, main = "DEM")
text(dem)
###asignar un sistema de coordenadas de referencia al DEM
crs(dem) <- CRS('+init=epsg:3115')
(slope = terrain(dem, 'slope', unit='degrees', neighbors=8))
## class : RasterLayer
## dimensions : 4, 4, 16 (nrow, ncol, ncell)
## resolution : 5.5, 5.5 (x, y)
## extent : 98, 120, 98, 120 (xmin, xmax, ymin, ymax)
## crs : +init=epsg:3115 +proj=tmerc +lat_0=4.596200416666666 +lon_0=-77.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
## source : memory
## names : slope
## values : 33.49771, 74.25374 (min, max)
plot(slope, main = "Pendiente")
text(slope)
(aspecto = terrain(dem, 'aspect', unit='degrees', neighbors=8))
## class : RasterLayer
## dimensions : 4, 4, 16 (nrow, ncol, ncell)
## resolution : 5.5, 5.5 (x, y)
## extent : 98, 120, 98, 120 (xmin, xmax, ymin, ymax)
## crs : +init=epsg:3115 +proj=tmerc +lat_0=4.596200416666666 +lon_0=-77.07750791666666 +k=1 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
## source : memory
## names : aspect
## values : 164.0546, 181.4688 (min, max)
plot(aspecto, main = "Aspecto")
text(aspecto)