-
Notifications
You must be signed in to change notification settings - Fork 19
/
raster-intro.R
53 lines (35 loc) · 1.1 KB
/
raster-intro.R
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
47
48
49
50
51
52
53
# Working through the intro raster course found here:
# https://datacarpentry.org/r-raster-vector-geospatial/01-raster-structure/index.html
library(raster)
library(rgdal)
library(ggplot2)
# Replace with path to file on your computer
data_path <- "raster-kriging/spring-2019/data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_dsmCrop.tif"
data_path2 <- "raster-kriging/spring-2019/data/NEON-DS-Airborne-Remote-Sensing/HARV/DSM/HARV_DSMhill.tif"
GDALinfo(data_path)
harv_dsm_metadata <- capture.output(GDALinfo(data_path))
harv_dsm_metadata
# Import raster data
harv_dsm <- raster(data_path)
harv_dsm
summary(harv_dsm, maxsamp = ncell(harv_dsm))
ncell(harv_dsm)
class(harv_dsm)
harv_df <- as.data.frame(harv_dsm, xy = TRUE)
class(harv_df)
head(harv_df)
str(harv_df)
ggplot() +
geom_raster(data = harv_df, aes(x = x, y = y, fill = HARV_dsmCrop)) +
scale_fill_viridis_c() +
coord_quickmap()
?coord_map
crs(harv_dsm)
minValue(harv_dsm)
maxValue(harv_dsm)
nlayers(harv_dsm)
GDALinfo(data_path)
ggplot() +
geom_histogram(data = harv_df,
aes(HARV_dsmCrop), bins = 40)
GDALinfo(data_path2)