This work was published in ------. If you use this code for your research, please consider citing:
-----@BIBTEX JOURNAL REFERENCE ------
Download the paper add link to paper
The motivation of this project is to develop a standardised computational approach to designing sample layouts for habitat fragmentations studies. Importantly we propose taking widely used fragmentation metric maps as inputs to the methods, which will output designs optimised to cover the metrics of interest.
Habitat fragmentation can be assessed with a wide range of different metrics, for example distance to habitat edges, fragment area, shape and configuration. While many studies aim to record impacts in relation to these metrics, in practice designing sample schemes which capture reponses to these measures can be challenging for three main reasons:
-
Fragmented landscapes present a complex mosaic which can be challenging to assess, making it difficult to optimally sample ranges of fragmentation metrics
-
Sample points are often placed in close proximity in the landscape leading to issues with spatial autocorrelation
-
Field researchers face challenges with inaccessible regions such as areas of private land, distance to research stations and unexpected obstacles such as landslides.
While it is common practice to use satellite dervied maps to quantify fragmentation metrics for a study landscape, to our knowledge these metric maps are predominantly used to extract metric values after sampling is completed. The novel approach we take in this study is to use these metric maps directly in the sampling design stage, allowing the configuration of metric values in the landscape to be quantitatively assessed. The methods are presented as open-source python code, and include features for masking innaccessible locations, suggesting optimal number of sample sites, and adapting partially completed designs given unforseen field-work imposed constraints.
In the topics below you can find an overview of the methods described in the paper, as well as samples showing how to use our code.
- Motivation
- Running jupyter demo files
- Package list
- Inputs
- Stratified Design Algorithm
- Uniform Design Algorithm
- Adapted Designs
The .ipynb files in this repository provide code demonstrations using the example files listed above, and can be run remotely via Google Colaboratory. This allows users to explore the code, load their own files, and generate designs without the need to download or install python or any extra libraries. To run these demo files please first download the test files here and then follow these instructions to get set up.
The following packages are required to run the code:
- conda 4.5.9
- numpy 1.15.0
- pandas 0.20.3
- click 6.7
- gdal 2.3.1
- matplotlib 2.1.0
- scipy 1.0.0
Spatial inputs fall into three main categories, as below. Example metric maps are provided in the input
folder, and can also be downloaded directly here. All map should be in georeferenced tif format.
- Habitat Map: A categorical map classifying the landscape into land-cover types, which should be the one used to produce the metric maps. In the example we have:
- HabitatMap.tif: A two-category grassland/forest map
- Invalid Areas Mask: Map showing areas to exclude (with 0=invalid / 1=valid). The example files include:
- InvalidAreasMask.tif: masks out all non-focal grassland habitat
- InvalidAreasMask_updated.tif: adds additional excluded regions which can be used to test the adapted design options
- Fragmentation Metric Maps: Maps showing some feature of fragmentation. The example files include:
- DistanceToEdgeLog2.tif: Log 2 transformed distance to edge (m, up to a maximum of 1024m)
- FragmentAreaLog10.tif: Log 10 transformed fragment area (ha)
Argument | Description | Example |
---|---|---|
--nsp |
number of sample sites | python generate_stratified_design.py --nsp=30 |
--mask_path |
path to mask tif file | python generate_stratified_design.py --mask_path=input/InvalidAreasMask.tif |
--hab_path |
path to categorical habitat map | python generate_uniform_design.py --hab_path=input/HabitatMap.tif |
--save_folder |
name of results folder | python generate_uniform_design.py --save_folder=uniform_design |
--metrics |
name of metric map | python generate_uniform_design.py --metrics=input/FragmentAreaLog10.tif |
--bins |
number of intervals metric sampled at | python generate_uniform_design.py --bins=7 |
The stratified design focuses only on spreading sites evenly geographically, given the layout of invalid areas. Invalid areas could include towns, roads, bodies of water, habitat types which are not of interest, areas in high elevation etc. The design is the building block for the uniform design algorithm.
Example generating a stratified design using the test files, with 30 sample sites, saving the output in folder called stratified-demo
:
python generate_stratified_design.py --mask_path=input/InvalidAreasMask.tif --save_folder=stratified-demo --nsp=30
The uniform design focuses on spreading sites as evenly as possible within the metric space, while at the same time maximising separation in geographic space. The requirements for this design is a habitat map and at least one fragmentation metric.
- Example generating a uniform design using one metric (distance to edge, split into 10 bins) and one habitat (masking out the other using an invalid areas mask), and 50 sample sites:
python generate_uniform_design.py --metrics=input/DistanceToEdgeLog2.tif --bins=10 --nsp=50 --save_folder=uniform-demo --mask_path=input/InvalidAreasMask.tif
- Example generating a two metric design (using 7 bins for fragment area, and 6 for distance to edge), and 80 sample sites
python generate_uniform_design.py --metrics=input/FragmentAreaLog10.tif --bins=7 --metrics=input/DistanceToEdgeLog2.tif --bins=6 --nsp=80 --save_folder=uniform-demo
Sometimes unforseen circumstances make it impossible to access certain locations. In this instance designs can be updated, keep all sites which have been successfully accessed in place. There are two options for adapting designs based on user preference, both involve tagging the csv file output by the original design which you will need to proceed:
In option 1 we manually update the invalid areas mask to include new inaccessible locations.
- In the
sampled
column of the csv file output by either the original design, put a one next to all sites which have been sampled already.
-
Manually update your invaild areas mask to include the new inaccessible areas, this could be done in software such as arcmap. An example updated map is provided in the
input
folder (InvaildAreasMask_updated.tif). -
Copy both these files to the
input
folder. -
Run the updated design option 1 code, all sites still tagged with a zero will be updated to a new optimal location. For example if the saved csv was called strat30-tagged.csv:
python update_stratified_design_opt1.py --save_folder=strat-adapted --updated_mask_path=input/InvalidAreasMask_updated.tif --csv_path=input/strat30-tagged.csv
In option 2 we exclude a user specified radius around selected inaccessible sample sites.
- In the
sampled
column of the csv file output by either the original design, put a one next to all sites which have already been sampled, and a two next to the site you would like to mask out
-
Copy this tagged csv to the
input
folder. -
Run the updated design option 2 code, and specify the radius (in metres) you would like to exclude around the site tagged with a two. You will also need to include the path to the original invalid areas mask. For example
python update_stratified_design_opt2.py --save_folder=strat-adapted --csv_path=input/strat30-tagged.csv --radius=1000 --original_mask_path=input/InvalidAreasMask.tif