This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the plot.
##My packages
library("ggplot2")
library("ggplot2")
theme_set(theme_bw())
library("sf")
## Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
library("rnaturalearth")
library("rnaturalearthdata")
##
## Attaching package: 'rnaturalearthdata'
## The following object is masked from 'package:rnaturalearth':
##
## countries110
library("ggrepel")
library ("ggspatial")
##My data
world = ne_countries(scale = "medium", returnclass = "sf") #database with countries name
LUCAS = read.csv("/Users/c055717/Documents/R/LUCAS/LUCAS-SOIL-2018 copy.csv")
point_id = LUCAS$POINTID
lat = LUCAS$TH_LAT
lon = LUCAS$TH_LONG
land_use = LUCAS$LC0_Desc
cover_type = LUCAS$LC1_Desc
lucas_land_use = data.frame(point_id, lat, lon, land_use, cover_type)
lucas_forest = lucas_land_use[lucas_land_use$land_use == "Woodland",]
lucas_forest_pine = lucas_forest[lucas_forest$cover_type == "Pine dominated coniferous woodland", ]
##my map
forest_point_map = ggplot(data = world) +
#background
geom_sf(color = "gray", fill = "white") +
#position the points
geom_point(data = lucas_forest, aes(x = lon, y = lat),
size = 2, shape = 20, col = "green") +
coord_sf(xlim = c(-10, 40), ylim = c(34, 70)) +
#title and SubTitle
ggtitle("LUCAS WOODLAND COVER", subtitle = paste("COVER TYPE")) +
#Axis labels
xlab("Longitude") +
ylab("Latitude") +
#scale
annotation_scale(location = "bl", width_hint = 0.5) +
#compass
annotation_north_arrow(location = "bl", which_north = "true", pad_x = unit(0.75, "in"),
pad_y = unit(0.5, "in"), style = north_arrow_fancy_orienteering)
print(forest_point_map)
## Scale on map varies by more than 10%, scale bar may be inaccurate
##my leaflet map
library(leaflet)
library(leaflet.extras)
library(magrittr)
heat_map_pine = leaflet(data = lucas_forest_pine) %>%
addProviderTiles("Esri.WorldImagery") %>%
addHeatmap(lng=~lon,lat=~lat,max=100,radius=20,blur=10)
heat_map_pine