ReefBiodiversityAccountSetup API
Spatial Analysis
ReefBiodiversityAccountSetup.spatial_analysis.filter_site_area
— Methodfilter_site_area(df::DataFrame)::DataFrame
Filter benthic data to only include polygons suitable for coral growth.
Arguments
df
: spatial data include benthic class column
ReefBiodiversityAccountSetup.spatial_analysis.get_depths
— Methodget_depths(reef_gdf::DataFrame, config_file::Dict; temporary_gpkg_name::String="spatial_data_temp.gpkg",)::Tuple{DataFrame,Array}
get_depths(reef_gdf::DataFrame, gbrmpa_region_path::String, gbrmpa_bathy_path::String; temporary_gpkg_name::String="spatial_data_temp.gpkg",)::Tuple{DataFrame,Array}
Get depths using data sourced from GBRMPA.
Arguments
config_file
: Dict of key filenames loaded from a "config.toml file"bathy_data_dir
: Directory for GBRMPA bathymetry datatemporary_gpkg_name
: Filename for temporary geopackage file saved in any previous steps.region_path
: Location of file containing regional GBRMPA spatial data.
ReefBiodiversityAccountSetup.spatial_analysis.get_geo_within_box
— Methodget_geo_within_box(geo_data::DataFrame, box_upper::Tuple, box_lower::Tuple)::DataFrame
Get geo_data
within specified bounding box.
Arguments
geo_data
: GeoDataFramebox_upper
: Upper coordinates for bounding boxbox_lower
: Lowert coordinates for bounding box
ReefBiodiversityAccountSetup.spatial_analysis.get_geomorphology_coral_area
— Methodget_geomorphology_coral_area(df_1::DataFrame, df_2::DataFrame)::DataFrame
Equivalent to a spatial join for df1 and df2, where the operation is intersection.
Arguments
df_1
: Inner dataframedf_2
: Outer dataframe
ReefBiodiversityAccountSetup.spatial_analysis.get_multipoly_area
— Methodget_multipoly_area(outer_gdf::DataFrame, inner_gdf::DataFrame)
Find the area of inner_gdf
intersecting with outer_gdf
.
Arguments
outer_gdf
: Outer dataframeinner_gdf
: Inner dataframe
ReefBiodiversityAccountSetup.spatial_analysis.load_spatial_base
— Methodload_spatial_base(config_file::Dict)
Loads key spatial data layers from an Allen Atlas dataset (benthic, geomorphic and extent (experimental)).
Returns
benthic
: Dataframe of polygons and their benthic classesgeomorphic
: Dataframe of polygons and their geomorphic classesreef_extent
: Dataframe of polygons showing reef extent (experiemental product in the Allen Atlas)
ReefBiodiversityAccountSetup.spatial_analysis.median_features_allen
— Methodmedian_features_allen(reef_gdf::DataFrame, config_file::Dict; temporary_gpkg_name::String="spatial_data_temp.gpkg", data_name::Symbol=:depth_med, is_depth=false)::Tuple{DataFrame,Array}
median_features_allen(reef_gdf::DataFrame, allen_bathy_filepath::String; temporary_gpkg_name::String="spatial_data_temp.gpkg", data_name::Symbol=:depth_med, is_depth=false)::Tuple{DataFrame,Array}
Get median values of an Allen Atlas Raster over a set of geometries
Arguments
config_file
: Dict of key filenames loaded from a "config.toml file"reef_gdf
: Current reef geodataframe to augmentallen_dir
: Directory for Allen Atlas Raster data (net cdf or tif)temporary_gpkg_name
: Filename for temporary geopackage file saved in any previous steps
ReefBiodiversityAccountSetup.spatial_analysis.multipoly_geom_intersection
— Methodmultipoly_geom_intersection(outer_gdf::DataFrame, inner_gdf::DataFrame, classes::Union{String,Symbol})
Find the intersections of outer_gdf
with each poly in inner_gdf
and combine to create new set of geometries with unique classes in inner_gdf
.
Arguments
outer_gdf
: Outer dataframeinner_gdf
: Inner dataframeclasses
: Vector giving the unique class of each polygon ininner_gdf
ReefBiodiversityAccountSetup.spatial_analysis.multipoly_geom_within
— Methodmultipoly_geom_within(outer_gdf::DataFrame, inner_gdf::DataFrame, classes::Union{String,Symbol})
Combine multipolygons in outer_gdf
of a particular class which sit inside the polygons of inner_gdf
Arguments
outer_gdf
: Outer dataframeinner_gdf
: Inner dataframeclasses
: Vector giving the unique class of each polygon ininner_gdf
ReefBiodiversityAccountSetup.spatial_analysis.noaa_dhw_means
— Methodnoaa_dhw_means(reef_gdf::DataFrame, config_file::Dict; temporary_gpkg_name::String="geomorph_temp.gpkg")::Tuple{DataFrame,YAXArray}
noaa_dhw_means(reef_gdf::DataFrame, dhw_filepath::String; temporary_gpkg_name::String="geomorph_temp.gpkg")::Tuple{DataFrame,YAXArray}
Get zonal mean values of the NOAA DHW product over a set of geometries in a geopackage.
Arguments
config_file
: Dict of key filenames loaded from a "config.toml file"reef_gdf
: Reef geodataframe to augmentdhw_fn
: Directory for NOAA DHW product datatemporary_gpkg_name
: Filename for temporary geopackage file saved in any previous steps.
ReefBiodiversityAccountSetup.spatial_analysis.normalize
— Methodnormalize(x)
Min-max normalisation of a vector
ReefBiodiversityAccountSetup.spatial_analysis.set_reef_k
— Methodset_reef_k(geomorphic_gdf::DataFrame, benthic_gdf::DataFrame; storage_string::String="spatial_data_temp.gpkg", threshold_k::Float64=0.05)
Set the proportional k area and total site area for the set of polygons in reef_gdf
, given a set of k areas (calculated using get_multipoly_area
).
Arguments
geomorphic_gdf
: geomorphic classes and polygons.benthic_gdf
: benthic classes and polygons.storage_string
: filename for temporary file saving to allow coordinate transforms and other manipulations.threshold_k
: threshold for k below which polygons are filtered out
ReefBiodiversityAccountSetup.spatial_analysis.suggest_control_sites
— Methodsuggest_control_sites(impact_site_id::Int64, site_data::DataFrame, category_constraints::Union{Vector{Symbol},Vector{String}}; weightings::Vector{Float64}=ones(size(site_data, 2) - (1 + length(category_constraints))), ID_COLUMN::Union{String,Symbol}=:reef_siteid, distance_func=chebyshev)::DataFrame
Output ordered list of sites which are similar to impact site. Similarity measured by normalised Chebyshev distance (or distance_func
where included).
Arguments
impact_site_id
: Id of site to be used to implement activities at.site_data
: Data to be used to judge similarity to impact site.category_constraints
: List of column names insite_data
which are categories that the impact and control sites must both sit within.weightings
: Weightings for the similarity criteria, to weight importance in control site selection. Default is equal weighting (all 1.0).ID_COLUMN
: Column insite_data
which is the unique identifier for sites.distance_func
: A distance function used to judge "similarity".
ReefBiodiversityAccountSetup.spatial_analysis.suggest_impact_sites
— Methodsuggest_impact_sites(site_data::DataFrame; min_site_karea::Float64=1000.0, sorted=true)::DataFrame
Calculate measure of suitable sites for implementing activities given a set of spatial data
Arguments
site_data
: Spatial dataset including geomorphic classes for each site.min_site_karea
: Minimum acceptable k area for sites to implement on.sorted
: true is output should be sorted from best to worst (don't use if using to plot map)
Plotting
ReefBiodiversityAccountSetup.plotting.set_axis_defaults
— Methodset_axis_defaults(axis_opts::Dict{Any,Any})::Dict{Symbol,Any}
Set default axis settings for spatial figures
ReefBiodiversityAccountSetup.plotting.set_figure_defaults
— Methodset_figure_defaults(fig_opts::Dict{Any,Any})::Dict{Symbol,Any}
Set default figure settings for spatial figures
ReefBiodiversityAccountSetup.plotting.spatial_map
— Methodspatial_map(geo_df::DataFrame, color_vec::Vector{String}; fig_opts::Dict{Symbol,Any}=set_figure_defaults(Dict()), axis_opts::Dict{Symbol,Any}=set_axis_defaults(Dict()), opts::Dict{Symbol,Any}=Dict())::Figure
spatial_map(f::Figure, geo_df::DataFrame, color_vec::Vector{String}; axis_opts::Dict{Symbol,Any}=set_axis_defaults(Dict()), opts::Dict{Symbol,Any}=Dict())::Figure
spatial_map(geo_df::DataFrame, color_vec::Union{Vector{Float32},Vector{Float64}}; axis_opts=Dict{Symbol,Any}=set_axis_defaults(Dict()), opts::Dict{Symbol,Any}=Dict())::Figure
spatial_map(f::Figure, geo_df::DataFrame, color_vec::Union{Vector{Float32},Vector{Float64}}; axis_opts::Dict{Symbol,Any}=set_axis_defaults(Dict()), opts::Dict{Symbol,Any}=Dict())::Figure
Plots a spatial heat map using a color vector of floats (for a continuous mapping) or a color vector of strings (for categorical mapping)
Arguments
geo_df
: GeoDataFrame containing geometries to be plottedcolor_vec
: Vector of values of length ofgeo_df
opts
: Aviz optionslegend_name
: name for legend showing categories and their colorscolorbar_label
: name for colorbar showing color rangecolor_map
: discretized colormap for categories or continuous for heatmapscolor_range
: Numerical limits for continuous colorbar
axis_opts
: Additional options to pass to adjust Axis attributes See: https://docs.makie.org/v0.19/api/index.html#Axis
ReefBiodiversityAccountSetup.plotting.temporal_spread
— Methodtemporal_spread(f::Figure, data::YAXArray; axis_opts::Dict{Symbol,<:Any}=set_figure_defaults(Dict{Symbol,Any}()), opts::Dict{Symbol,<:Any}=set_figure_defaults(Dict{Symbol,Any}()))
Plot median of a data set over time with colored bands representing the 1st, 2nd and 3rd quantiles.
Arguments
data
: Must include a :timesteps dimension + 2 other dimsopts
: Plotting options -plot_color
: Color of lines and bandsaxis_opts
: Additional options to pass to adjust Axis attributes -ylabel
: Label for the metric being plotted See: https://docs.makie.org/v0.19/api/index.html#Axisseries_opts
: Additional options to pass to adjust Series attributes See: https://docs.makie.org/v0.19/api/index.html#series!