ReefBiodiversityAccountSetup API

Spatial Analysis

ReefBiodiversityAccountSetup.spatial_analysis.get_depthsMethod
get_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 data
  • temporary_gpkg_name : Filename for temporary geopackage file saved in any previous steps.
  • region_path : Location of file containing regional GBRMPA spatial data.
source
ReefBiodiversityAccountSetup.spatial_analysis.load_spatial_baseMethod
load_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 classes
  • geomorphic : Dataframe of polygons and their geomorphic classes
  • reef_extent : Dataframe of polygons showing reef extent (experiemental product in the Allen Atlas)
source
ReefBiodiversityAccountSetup.spatial_analysis.median_features_allenMethod
median_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 augment
  • allen_dir : Directory for Allen Atlas Raster data (net cdf or tif)
  • temporary_gpkg_name : Filename for temporary geopackage file saved in any previous steps
source
ReefBiodiversityAccountSetup.spatial_analysis.multipoly_geom_intersectionMethod
multipoly_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 dataframe
  • inner_gdf : Inner dataframe
  • classes : Vector giving the unique class of each polygon in inner_gdf
source
ReefBiodiversityAccountSetup.spatial_analysis.multipoly_geom_withinMethod
multipoly_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 dataframe
  • inner_gdf : Inner dataframe
  • classes : Vector giving the unique class of each polygon in inner_gdf
source
ReefBiodiversityAccountSetup.spatial_analysis.noaa_dhw_meansMethod
noaa_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 augment
  • dhw_fn : Directory for NOAA DHW product data
  • temporary_gpkg_name : Filename for temporary geopackage file saved in any previous steps.
source
ReefBiodiversityAccountSetup.spatial_analysis.set_reef_kMethod
set_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
source
ReefBiodiversityAccountSetup.spatial_analysis.suggest_control_sitesMethod
suggest_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 in site_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 in site_data which is the unique identifier for sites.
  • distance_func : A distance function used to judge "similarity".
source
ReefBiodiversityAccountSetup.spatial_analysis.suggest_impact_sitesMethod
suggest_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)
source

Plotting

ReefBiodiversityAccountSetup.plotting.spatial_mapMethod
spatial_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 plotted
  • color_vec : Vector of values of length of geo_df
  • opts : Aviz options
    • legend_name : name for legend showing categories and their colors
    • colorbar_label : name for colorbar showing color range
    • color_map : discretized colormap for categories or continuous for heatmaps
    • color_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
source
ReefBiodiversityAccountSetup.plotting.temporal_spreadMethod
temporal_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 dims
  • opts : Plotting options -plot_color : Color of lines and bands
  • axis_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#Axis
  • series_opts : Additional options to pass to adjust Series attributes See: https://docs.makie.org/v0.19/api/index.html#series!
source