R Package to simplify the acquisition of data in Google Earth Engine and performs several steps of organization and processing typical of ecological studies, allowing pre-processing, visualization, data download and calculation of simple statistics commonly used in ecological studies. It aims to simplify the use of rgee and Google Earth Engine commands, performing internally several data manipulation steps. The function syntax follows a familiar style for R users who perform statistical analysis in ecology.
Requires pre-registration on the Google Earth Engine platform (https://earthengine.google.com/).
Install package dependencies from CRAN:
install.packages("sf")
install.packages("googledrive")
install.packages("dplyr")
install.packages("readODS")
install.packages("remotes")
install.packages("rgee")
Install additional dependency from GitHub:
library(remotes) #derived from devtools package
install_github("r-earthengine/rgeeExtra")
Configure rgee Phyton integration. See rgee page for details or follow the steps below:
library(rgee)
ee_install()
ee_check() # Check non-R dependencies (optional)
Install ecors:
install_github("fredtaka/ecors")
Load some sf features to use as site (polygons), plots (polygons) and points (points):
library(sf)
FAL.IBGE.JBB<-st_read(system.file("extdata/FAL.IBGE.JBB.gpkg", package="ecors"))
test.plots<-st_read(system.file("extdata/Plots_tests.gpkg", package="ecors"))
test.points<-st_read(system.file("extdata/Points_tests.gpkg", package="ecors"))
Ask ecors to select good images and make some pre-processing:
library(ecors)
d2020<-get.ecors(site=FAL.IBGE.JBB, points=test.points, plots=test.plots,
buffer.points=100, buffer.plots=100,
projected=F, custom.crs=32723,
collection="LANDSAT/LC08/C02/T1_L2",
start=c("2020-01-01"), end=c("2020-12-31"),
bands.eval=c("SR_B3","SR_B4"), bands.vis=T, indices=c("NDVI"), resolution=30,
eval.area="samples", pOK=0.7, c.prob=NULL, c.dist=100,
seasons=list(s1=c(11,12,1,2), s2=c(3,4), s3=c(5,6,7,8), s4=c(9,10)), group.by="season",
composite="mean")
Plotting options:
plot(x=d2020, ecors.type="filtered+mask")
plot(x=d2020, ecors.type="mask", visualization="custom", defaults=F,
legend=T, bands="NDVI", pixel.min=-1, pixel.max=1, image.gamma=NULL)
plot(x=d2020, ecors.type="composite")
Compute the average of the pixel values of each sampling unit (buffer around points and buffered plots) in each image and in the set of images for each season:
mean_d2020<-stats.ecors(x=d2020, edge.pixels="weighted", remove.samples=list(num.pixelOK=10,prop.pixelOK=0.8),
summarizing="all", by.image.save=T, summary.save=T,
stats=list(mean=T,median=F,sd=F,count=F),spreadsheet.folder=getwd() )
mean_d2020
Download the images cropped to include the study site and small extra area around it:
download.ecors(x=d2020, ecors.type="composite",vis.bands=T,
ref.site=T,exp.degree=0.05,
images.folder=getwd(),clear.prov=F)
Get land use map in the areas surrounding the site:
lu90_00_20<-get.lu.ecors(site=FAL.IBGE.JBB,
projected=F, custom.crs=32723,
collection.lu="mapbiomas6", years=c(1990,2000,2020),
evaluate="surroundings.site",
buffer1=5000, buffer2=10000, buffer3=20000, cumulative.surroundings=F)
Create a interactive visualization:
plot(x=lu90_00_20)
Quantifies the pixels of each land use class in each influence zone on the site (results will be saved as files):
quantify.lu.ecors(x=lu90_00_20, save.format=c("ods"))
Calculate the minimum distance from sampling points (mostly savanna) to areas of forest vegetation (gallery forests): - Get the land use data - Merge two land use classes that represents forests (pixel value 1 and 3) - Calculate the minimum distance to a forest pixel
lu20<-get.lu.ecors(points=test.points,
projected=F, custom.crs=32723,
collection.lu="mapbiomas6", years=c(2020),
evaluate="distance.samples")
conv_lu20<-convert.lu.ecors(x=lu20,old.value = c(1,3),
new.value = c(1,1), new.lu.class = c("Forest","Forest"))
dist_to_forest<-dist.lu.ecors(x=conv_lu20, class.value=1, stat.dist="min", max.dist=5000)
Download land use maps cropped to include the study site and small extra area around it:
download.lu.ecors(x=lu90_00_20, exp.degree=0.05)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.