A package to plot survey and density maps.
A package with functions to make maps
Contains data:
- Data from a random generated survey in CRS 3035 and CRS 4326
- A grid generated using the function create_grid in CRS 3035
Contains functions:
- transform_survey
- subset_grid
- grid_densities
- plot_density
- add_breaks
- add_legend
- add_theme
You can install the development version of seamonas from GitHub with:
# install.packages("devtools")
devtools::install_github("MiriamLL/seamonas")
head(survey_4326)
Data from a survey including longitude, latitude, timestamp
survey_4326<-survey_4326
ggplot2::ggplot()+
ggplot2::geom_point(data=survey_4326,
ggplot2::aes(x=longitude, y= latitude, color=date),size = 1, shape = 16)
A data frame with survey data including observations
density_survey
A grid 5x5 in CRS 3035
grid5x5_3035<-grid5x5_3035
plot(grid5x5_3035)
The surveyed grid, this means the grid cells were data was collected
grid_surveyed
A function to transform data collected in latitude and longitude from degrees, transform from 4326 to 3035
survey_3035<-transform_survey(survey_data=survey_4326,
column_latitude='latitude',
column_longitude='longitude',
from_CRS=4326,
to_CRS=3035)
Add values to geometries of the grid, each square is a geometry or polygon There will be warning that variables are assumed to be spatially constant throughout all geometries Will print a plot and return the grids with data
grid_surveyed<-subset_grid(survey_grid=grid5x5_3035,
survey_data=survey_3035,
grid_identifier='grid_id')
Plot to check grid
A series of functions to go from a data frame of surveyed data to a grid
A function to transform the CRS
densities_3035<-transform_survey(survey_data=density_survey,
column_latitude='latitude',
column_longitude='longitude',
from_CRS=4326,
to_CRS=3035)
A function to keep only grids with data
density_grid<-subset_density(density_survey=densities_3035,column_density='densities',
survey_grid=grid_surveyed,grid_identifier='grid_id')
Check the data
Base data
my_CRS<-3035
Europa<-sf::st_transform(GermanNorthSea::German_land, my_CRS)
EEZ<-sf::st_transform(GermanNorthSea::German_EEZ, my_CRS)
color_land='#f7bf54'
color_water='#3668b4'
xval<-c(3910000,4250000)
yval<-c(3380000,3680000)
Provide density grid and mean densities
density_plot<-ggplot2::ggplot()+
# maps
ggplot2::geom_sf(data = EEZ, colour = 'black', fill = color_water)+
ggplot2::geom_sf(data = Europa, colour = 'black', fill = color_land)+
ggplot2::geom_sf(data = density_grid,
mapping = ggplot2::aes(fill = mean_density), lwd = 0, colour = NA) +
ggplot2::coord_sf(xlim = xval, ylim = yval)+
NULL
density_plot
A function to add color palette and breaks in the legend, will vary with the species density estimates
plot_wbreaks<-add_breaks(density_plot=density_plot,
legendbreaks=c(0,0.5,1,1.5,2.0),
legendlimits=c(0,2),
legendlabels=c(' 0',' 0.5',' 1.0',' 1.5','> 2.0'))
plot_wbreaks
A function to add the legend inside the plot
plot_wlegend<-add_legend(
plot_wbreaks=plot_wbreaks,
legtx=3905000,
legty=3510000,
legxy=c(0.11, 0.21),
xval=c(3910000,4250000),
yval=c(3380000,3680000))
plot_wlegend
A function to define the theme
plot_wtheme<-add_theme(plot_wlegend = plot_wlegend)
plot_wtheme