aoh 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aoh-1.0.1/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ ISC License
2
+
3
+ Copyright 2022-2024 Michael Dales <mwd24@cam.ac.uk>
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
aoh-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: aoh
3
+ Version: 1.0.1
4
+ Summary: A library for calculating Area of Habitat for species distribution mapping
5
+ Author-email: Michael Dales <mwd24@cam.ac.uk>
6
+ License-Expression: ISC
7
+ Project-URL: Homepage, https://github.com/quantifyearth/aoh-calculator
8
+ Project-URL: Repository, https://github.com/quantifyearth/aoh-calculator
9
+ Project-URL: Issues, https://github.com/quantifyearth/aoh-calculator/issues
10
+ Keywords: gis,species,habitat,biodiversity,ecology
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: GIS
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: alive-progress
22
+ Requires-Dist: numpy<3.0,>=1.24
23
+ Requires-Dist: geopandas<2.0,>=1.0
24
+ Requires-Dist: psutil
25
+ Requires-Dist: pyproj<4.0,>=3.4
26
+ Requires-Dist: scikit-image<1.0,>=0.20
27
+ Requires-Dist: yirgacheffe<2.0,>=1.7.8
28
+ Requires-Dist: zenodo_search
29
+ Requires-Dist: pandas<3.0,>=2.0
30
+ Requires-Dist: gdal[numpy]<3.12,>=3.8
31
+ Requires-Dist: tomli
32
+ Provides-Extra: validation
33
+ Requires-Dist: pymer4==0.8.2; extra == "validation"
34
+ Provides-Extra: dev
35
+ Requires-Dist: pylint; extra == "dev"
36
+ Requires-Dist: mypy; extra == "dev"
37
+ Requires-Dist: pytest; extra == "dev"
38
+ Requires-Dist: types-psutil; extra == "dev"
39
+ Requires-Dist: pandas-stubs; extra == "dev"
40
+ Requires-Dist: geojson; extra == "dev"
41
+ Requires-Dist: pytest-cov; extra == "dev"
42
+ Requires-Dist: build; extra == "dev"
43
+ Requires-Dist: twine; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # AOH Calculator
47
+
48
+ This repository contains code for making Area of Habitat (AOH) rasters from a mix of data sources, following the methodology described in [Brooks et al](https://www.cell.com/trends/ecology-evolution/fulltext/S0169-5347(19)30189-2) and adhering to the IUCN Redlist Technical Working Group guidance on AoH production. This work is part of the [LIFE biodiversity map](https://www.cambridge.org/engage/coe/article-details/660e6f08418a5379b00a82b2) work at the University of Cambridge. It also contains some scripts for summarising AOH data into maps of species richness and species endemism.
49
+
50
+ ## Installation
51
+
52
+ The AOH Calculator is available as a Python package and can be installed via pip:
53
+
54
+ ```bash
55
+ pip install aoh
56
+ ```
57
+
58
+ This provides both command-line tools and a Python library for programmatic use.
59
+
60
+ For validation tools that require R, install with the validation extra:
61
+
62
+ ```bash
63
+ pip install aoh[validation]
64
+ ```
65
+
66
+ ### Prerequisites
67
+
68
+ You'll need GDAL installed on your system. The Python GDAL package version should match your system GDAL version. You can check your GDAL version with:
69
+
70
+ ```bash
71
+ gdalinfo --version
72
+ ```
73
+
74
+ Then install the matching Python package:
75
+
76
+ ```bash
77
+ pip install gdal[numpy]==YOUR_VERSION_HERE
78
+ ```
79
+
80
+ ### Library Usage
81
+
82
+ You can also use AOH Calculator as a Python library:
83
+
84
+ ```python
85
+ import aoh
86
+ from aoh import tidy_data
87
+ from aoh.summaries import species_richness
88
+ from aoh.validation import collate_data
89
+
90
+ # Use core functions programmatically
91
+ # See function documentation for parameters
92
+ ```
93
+
94
+ To generate a set of AOH rasters you will need:
95
+
96
+ - IUCN range and other metadata (habitat preference, elevation, seasonality)
97
+ - A habitat map raster
98
+ - An elevation map raster
99
+
100
+ The raster maps must be at the same scale. This code has been used with Lumbierres, Jung, and ESA datasets successfully, and using Mercator, Mollweide, and Behrmann projections.
101
+
102
+ For examples on how to run the code see the docs directory.
103
+
104
+ This project makes heavy use of [Yirgacheffe](https://github.com/quantifyearth/yirgacheffe) to do the numerical work, and the code in this repository is mostly for getting the data to feed to yirgacheffe. The advantages of using Yirgacheffe are that it hides all the offsetting required for the math to keep the AoH logic simple, deals with the archaic GDAL API bindings, and uses map chunking to mean progress can made with minimal memory footprints despite some base map rasters being 150GB and up.
105
+
106
+ # Command Line Tools
107
+
108
+ ## aoh-calc
109
+
110
+ This is the main command designed to calculate the AOH of a single species.
111
+
112
+ ```bash
113
+ $ aoh-calc --help
114
+ usage: aoh-calc [-h] --habitats HABITAT_PATH
115
+ --elevation-min MIN_ELEVATION_PATH
116
+ --elevation-max MAX_ELEVATION_PATH [--area AREA_PATH]
117
+ --crosswalk CROSSWALK_PATH --speciesdata SPECIES_DATA_PATH
118
+ [--force-habitat] --output OUTPUT_PATH
119
+
120
+ Area of habitat calculator.
121
+
122
+ options:
123
+ -h, --help show this help message and exit
124
+ --habitats HABITAT_PATH
125
+ Directory of habitat rasters, one per habitat class.
126
+ --elevation-min MIN_ELEVATION_PATH
127
+ Minimum elevation raster.
128
+ --elevation-max MAX_ELEVATION_PATH
129
+ Maximum elevation raster
130
+ --area AREA_PATH Optional area per pixel raster. Can be 1xheight.
131
+ --crosswalk CROSSWALK_PATH
132
+ Path of habitat crosswalk table.
133
+ --speciesdata SPECIES_DATA_PATH
134
+ Single species/seasonality geojson.
135
+ --force-habitat If set, don't treat an empty habitat layer layer as
136
+ per IRTWG.
137
+ --output OUTPUT_PATH Directory where area geotiffs should be stored.
138
+ ```
139
+
140
+ To calculate the AoH we need the following information:
141
+
142
+ - Species data: A GeoJSON file that contains at least the following values about the species in question:
143
+ - id_no: the IUCN taxon ID of the species
144
+ - seasonal: the season using IUCN codes (1 = resident, 2 = breeding, 3 = non-breeding, 4 = passage, 5 = unknown)
145
+ - elevation_upper: The upper bound of elevation in which species is found
146
+ - elevation_lower: The lower bound of elevation in which species is found
147
+ - full_habitat_code: A list of the IUCN habitat codes in which the species is found
148
+ - geometry: A polygon or multipolygon describing the range of the species in that season
149
+ - Habitats: A directory containing a series of GeoTIFFs, one per habitat class, indicating which pixels contain that habitat. Float values indicate partial occupancy.
150
+ - Elevation-max/Elevation-min: Two GeoTIFFs, in which the highest and lowest elevation for that pixel is recorded. Must be in same units as those in the GeoJSON.
151
+ - Crosswalk: A crosswalk table in CSV format that converts between the IUCN habitat classes and names of the habitat raster layers.
152
+ - Area: An optiona raster containing the area of each pixel, which will be multipled with the AoH raster before saving to produce a result in area rather than pixel occupancy.
153
+ - Force habitat: An optional flag that means rather than following the IUCN RLTWG guidelines, whereby if there is zero area in the habitat layer after filtering for species habitat preferneces we should revert to range, this flag will keep the result as zero. This is to allow for evaluation of scenarios that might lead to extinction via land use chnages.
154
+ - Output directory - Two files will be output to this directory: an AoH raster with the format `{id_no}_{seasonal}.tif` and a manifest containing information about the raster `{id_no}_{seasonal}.json`.
155
+
156
+ ## aoh-habitat-process
157
+
158
+ Whilst for terrestrial AOH calculations there is normally just one habitat class per pixel, for other realms like marine (which is a 3D space) this isn't necessarily the case. To allow this package to work for all realms, we must split out terrestrial habitat maps that combine all classes into a single raster into per layer rasters. To assist with this, we provide the `aoh-habitat-process` command, which also allows for rescaling and reprojecting.
159
+
160
+ ```bash
161
+ $ aoh-habitat-process --help
162
+ usage: aoh-habitat-process [-h] --habitat HABITAT_PATH --scale PIXEL_SCALE
163
+ [--projection TARGET_PROJECTION]
164
+ --output OUTPUT_PATH [-j PROCESSES_COUNT]
165
+
166
+ Downsample habitat map to raster per terrain type.
167
+
168
+ options:
169
+ -h, --help show this help message and exit
170
+ --habitat HABITAT_PATH
171
+ Path of initial combined habitat map.
172
+ --scale PIXEL_SCALE Optional output pixel scale value, otherwise same as
173
+ source.
174
+ --projection TARGET_PROJECTION
175
+ Optional target projection, otherwise same as source.
176
+ --output OUTPUT_PATH Destination folder for raster files.
177
+ -j PROCESSES_COUNT Optional number of concurrent threads to use.
178
+ ```
179
+
180
+ # Summary Tools
181
+
182
+ These commands take a set of AOH maps and generate summary statistics useful for analysing groups of species.
183
+
184
+ ## aoh-species-richness
185
+
186
+ The species richness map is just an indicator of how many species exist in a given area. It takes each AOH map, converts it to a boolean layer to indicate presence, and then sums the resulting boolean raster layers to give you a count in each pixel of how many species are there.
187
+
188
+ ```bash
189
+ $ aoh-species-richness --help
190
+ usage: aoh-species-richness [-h] --aohs_folder AOHS --output OUTPUT
191
+ [-j PROCESSES_COUNT]
192
+
193
+ Calculate species richness
194
+
195
+ options:
196
+ -h, --help show this help message and exit
197
+ --aohs_folder AOHS Folder containing set of AoHs
198
+ --output OUTPUT Destination GeoTIFF file for results.
199
+ -j PROCESSES_COUNT Number of concurrent threads to use.
200
+ ```
201
+
202
+ ## aoh-endemism
203
+
204
+ Endemism is an indicator of how much an area of land contributes to a species overall habitat: for a species with a small area of habitat then each pixel is more precious to it than it is for a species with a vast area over which they can be found. The endemism map takes the set of AoHs and the species richness map to generate, and for each species works out the proportion of its AoH is within a given pixel, and calculates the geometric mean per pixel across all species in that pixel.
205
+
206
+ ```bash
207
+ $ aoh-endemism --help
208
+ usage: aoh-endemism [-h] --aohs_folder AOHS
209
+ --species_richness SPECIES_RICHNESS --output OUTPUT
210
+ [-j PROCESSES_COUNT]
211
+
212
+ Calculate species richness
213
+
214
+ options:
215
+ -h, --help show this help message and exit
216
+ --aohs_folder AOHS Folder containing set of AoHs
217
+ --species_richness SPECIES_RICHNESS
218
+ GeoTIFF containing species richness
219
+ --output OUTPUT Destination GeoTIFF file for results.
220
+ -j PROCESSES_COUNT Number of concurrent threads to use.
221
+ ```
222
+
223
+ # Validation Tools
224
+
225
+ In [Dahal et al](https://gmd.copernicus.org/articles/15/5093/2022/) there is a method described for validating a set of AoH maps. This is implemented as validation commands, and borrows heavily from work by [Franchesca Ridley](https://www.researchgate.net/profile/Francesca-Ridley).
226
+
227
+ ## aoh-collate-data
228
+
229
+ Before running validation, the metadata provided for each AoH map must be collated into a single table using this command:
230
+
231
+ ```bash
232
+ $ aoh-collate-data --help
233
+ usage: aoh-collate-data [-h] --aoh_results AOHS_PATH --output OUTPUT_PATH
234
+
235
+ Collate metadata from AoH build.
236
+
237
+ options:
238
+ -h, --help show this help message and exit
239
+ --aoh_results AOHS_PATH
240
+ Path of all the AoH outputs.
241
+ --output OUTPUT_PATH Destination for collated CSV.
242
+ ```
243
+
244
+ ## aoh-validate-prevalence
245
+
246
+ To run the model validation use this command:
247
+
248
+ ```bash
249
+ $ aoh-validate-prevalence --help
250
+ usage: aoh-validate-prevalence [-h] --collated_aoh_data COLLATED_DATA_PATH
251
+ --output OUTPUT_PATH
252
+
253
+ Validate map prevalence.
254
+
255
+ options:
256
+ -h, --help show this help message and exit
257
+ --collated_aoh_data COLLATED_DATA_PATH
258
+ CSV containing collated AoH data
259
+ --output OUTPUT_PATH CSV of outliers.
260
+ ```
261
+
262
+ This will produce a CSV file listing just the AoH maps that fail model validation.
263
+
264
+ **Note:** The validation tools require R to be installed on your system with the `lme4` and `lmerTest` packages.
aoh-1.0.1/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # AOH Calculator
2
+
3
+ This repository contains code for making Area of Habitat (AOH) rasters from a mix of data sources, following the methodology described in [Brooks et al](https://www.cell.com/trends/ecology-evolution/fulltext/S0169-5347(19)30189-2) and adhering to the IUCN Redlist Technical Working Group guidance on AoH production. This work is part of the [LIFE biodiversity map](https://www.cambridge.org/engage/coe/article-details/660e6f08418a5379b00a82b2) work at the University of Cambridge. It also contains some scripts for summarising AOH data into maps of species richness and species endemism.
4
+
5
+ ## Installation
6
+
7
+ The AOH Calculator is available as a Python package and can be installed via pip:
8
+
9
+ ```bash
10
+ pip install aoh
11
+ ```
12
+
13
+ This provides both command-line tools and a Python library for programmatic use.
14
+
15
+ For validation tools that require R, install with the validation extra:
16
+
17
+ ```bash
18
+ pip install aoh[validation]
19
+ ```
20
+
21
+ ### Prerequisites
22
+
23
+ You'll need GDAL installed on your system. The Python GDAL package version should match your system GDAL version. You can check your GDAL version with:
24
+
25
+ ```bash
26
+ gdalinfo --version
27
+ ```
28
+
29
+ Then install the matching Python package:
30
+
31
+ ```bash
32
+ pip install gdal[numpy]==YOUR_VERSION_HERE
33
+ ```
34
+
35
+ ### Library Usage
36
+
37
+ You can also use AOH Calculator as a Python library:
38
+
39
+ ```python
40
+ import aoh
41
+ from aoh import tidy_data
42
+ from aoh.summaries import species_richness
43
+ from aoh.validation import collate_data
44
+
45
+ # Use core functions programmatically
46
+ # See function documentation for parameters
47
+ ```
48
+
49
+ To generate a set of AOH rasters you will need:
50
+
51
+ - IUCN range and other metadata (habitat preference, elevation, seasonality)
52
+ - A habitat map raster
53
+ - An elevation map raster
54
+
55
+ The raster maps must be at the same scale. This code has been used with Lumbierres, Jung, and ESA datasets successfully, and using Mercator, Mollweide, and Behrmann projections.
56
+
57
+ For examples on how to run the code see the docs directory.
58
+
59
+ This project makes heavy use of [Yirgacheffe](https://github.com/quantifyearth/yirgacheffe) to do the numerical work, and the code in this repository is mostly for getting the data to feed to yirgacheffe. The advantages of using Yirgacheffe are that it hides all the offsetting required for the math to keep the AoH logic simple, deals with the archaic GDAL API bindings, and uses map chunking to mean progress can made with minimal memory footprints despite some base map rasters being 150GB and up.
60
+
61
+ # Command Line Tools
62
+
63
+ ## aoh-calc
64
+
65
+ This is the main command designed to calculate the AOH of a single species.
66
+
67
+ ```bash
68
+ $ aoh-calc --help
69
+ usage: aoh-calc [-h] --habitats HABITAT_PATH
70
+ --elevation-min MIN_ELEVATION_PATH
71
+ --elevation-max MAX_ELEVATION_PATH [--area AREA_PATH]
72
+ --crosswalk CROSSWALK_PATH --speciesdata SPECIES_DATA_PATH
73
+ [--force-habitat] --output OUTPUT_PATH
74
+
75
+ Area of habitat calculator.
76
+
77
+ options:
78
+ -h, --help show this help message and exit
79
+ --habitats HABITAT_PATH
80
+ Directory of habitat rasters, one per habitat class.
81
+ --elevation-min MIN_ELEVATION_PATH
82
+ Minimum elevation raster.
83
+ --elevation-max MAX_ELEVATION_PATH
84
+ Maximum elevation raster
85
+ --area AREA_PATH Optional area per pixel raster. Can be 1xheight.
86
+ --crosswalk CROSSWALK_PATH
87
+ Path of habitat crosswalk table.
88
+ --speciesdata SPECIES_DATA_PATH
89
+ Single species/seasonality geojson.
90
+ --force-habitat If set, don't treat an empty habitat layer layer as
91
+ per IRTWG.
92
+ --output OUTPUT_PATH Directory where area geotiffs should be stored.
93
+ ```
94
+
95
+ To calculate the AoH we need the following information:
96
+
97
+ - Species data: A GeoJSON file that contains at least the following values about the species in question:
98
+ - id_no: the IUCN taxon ID of the species
99
+ - seasonal: the season using IUCN codes (1 = resident, 2 = breeding, 3 = non-breeding, 4 = passage, 5 = unknown)
100
+ - elevation_upper: The upper bound of elevation in which species is found
101
+ - elevation_lower: The lower bound of elevation in which species is found
102
+ - full_habitat_code: A list of the IUCN habitat codes in which the species is found
103
+ - geometry: A polygon or multipolygon describing the range of the species in that season
104
+ - Habitats: A directory containing a series of GeoTIFFs, one per habitat class, indicating which pixels contain that habitat. Float values indicate partial occupancy.
105
+ - Elevation-max/Elevation-min: Two GeoTIFFs, in which the highest and lowest elevation for that pixel is recorded. Must be in same units as those in the GeoJSON.
106
+ - Crosswalk: A crosswalk table in CSV format that converts between the IUCN habitat classes and names of the habitat raster layers.
107
+ - Area: An optiona raster containing the area of each pixel, which will be multipled with the AoH raster before saving to produce a result in area rather than pixel occupancy.
108
+ - Force habitat: An optional flag that means rather than following the IUCN RLTWG guidelines, whereby if there is zero area in the habitat layer after filtering for species habitat preferneces we should revert to range, this flag will keep the result as zero. This is to allow for evaluation of scenarios that might lead to extinction via land use chnages.
109
+ - Output directory - Two files will be output to this directory: an AoH raster with the format `{id_no}_{seasonal}.tif` and a manifest containing information about the raster `{id_no}_{seasonal}.json`.
110
+
111
+ ## aoh-habitat-process
112
+
113
+ Whilst for terrestrial AOH calculations there is normally just one habitat class per pixel, for other realms like marine (which is a 3D space) this isn't necessarily the case. To allow this package to work for all realms, we must split out terrestrial habitat maps that combine all classes into a single raster into per layer rasters. To assist with this, we provide the `aoh-habitat-process` command, which also allows for rescaling and reprojecting.
114
+
115
+ ```bash
116
+ $ aoh-habitat-process --help
117
+ usage: aoh-habitat-process [-h] --habitat HABITAT_PATH --scale PIXEL_SCALE
118
+ [--projection TARGET_PROJECTION]
119
+ --output OUTPUT_PATH [-j PROCESSES_COUNT]
120
+
121
+ Downsample habitat map to raster per terrain type.
122
+
123
+ options:
124
+ -h, --help show this help message and exit
125
+ --habitat HABITAT_PATH
126
+ Path of initial combined habitat map.
127
+ --scale PIXEL_SCALE Optional output pixel scale value, otherwise same as
128
+ source.
129
+ --projection TARGET_PROJECTION
130
+ Optional target projection, otherwise same as source.
131
+ --output OUTPUT_PATH Destination folder for raster files.
132
+ -j PROCESSES_COUNT Optional number of concurrent threads to use.
133
+ ```
134
+
135
+ # Summary Tools
136
+
137
+ These commands take a set of AOH maps and generate summary statistics useful for analysing groups of species.
138
+
139
+ ## aoh-species-richness
140
+
141
+ The species richness map is just an indicator of how many species exist in a given area. It takes each AOH map, converts it to a boolean layer to indicate presence, and then sums the resulting boolean raster layers to give you a count in each pixel of how many species are there.
142
+
143
+ ```bash
144
+ $ aoh-species-richness --help
145
+ usage: aoh-species-richness [-h] --aohs_folder AOHS --output OUTPUT
146
+ [-j PROCESSES_COUNT]
147
+
148
+ Calculate species richness
149
+
150
+ options:
151
+ -h, --help show this help message and exit
152
+ --aohs_folder AOHS Folder containing set of AoHs
153
+ --output OUTPUT Destination GeoTIFF file for results.
154
+ -j PROCESSES_COUNT Number of concurrent threads to use.
155
+ ```
156
+
157
+ ## aoh-endemism
158
+
159
+ Endemism is an indicator of how much an area of land contributes to a species overall habitat: for a species with a small area of habitat then each pixel is more precious to it than it is for a species with a vast area over which they can be found. The endemism map takes the set of AoHs and the species richness map to generate, and for each species works out the proportion of its AoH is within a given pixel, and calculates the geometric mean per pixel across all species in that pixel.
160
+
161
+ ```bash
162
+ $ aoh-endemism --help
163
+ usage: aoh-endemism [-h] --aohs_folder AOHS
164
+ --species_richness SPECIES_RICHNESS --output OUTPUT
165
+ [-j PROCESSES_COUNT]
166
+
167
+ Calculate species richness
168
+
169
+ options:
170
+ -h, --help show this help message and exit
171
+ --aohs_folder AOHS Folder containing set of AoHs
172
+ --species_richness SPECIES_RICHNESS
173
+ GeoTIFF containing species richness
174
+ --output OUTPUT Destination GeoTIFF file for results.
175
+ -j PROCESSES_COUNT Number of concurrent threads to use.
176
+ ```
177
+
178
+ # Validation Tools
179
+
180
+ In [Dahal et al](https://gmd.copernicus.org/articles/15/5093/2022/) there is a method described for validating a set of AoH maps. This is implemented as validation commands, and borrows heavily from work by [Franchesca Ridley](https://www.researchgate.net/profile/Francesca-Ridley).
181
+
182
+ ## aoh-collate-data
183
+
184
+ Before running validation, the metadata provided for each AoH map must be collated into a single table using this command:
185
+
186
+ ```bash
187
+ $ aoh-collate-data --help
188
+ usage: aoh-collate-data [-h] --aoh_results AOHS_PATH --output OUTPUT_PATH
189
+
190
+ Collate metadata from AoH build.
191
+
192
+ options:
193
+ -h, --help show this help message and exit
194
+ --aoh_results AOHS_PATH
195
+ Path of all the AoH outputs.
196
+ --output OUTPUT_PATH Destination for collated CSV.
197
+ ```
198
+
199
+ ## aoh-validate-prevalence
200
+
201
+ To run the model validation use this command:
202
+
203
+ ```bash
204
+ $ aoh-validate-prevalence --help
205
+ usage: aoh-validate-prevalence [-h] --collated_aoh_data COLLATED_DATA_PATH
206
+ --output OUTPUT_PATH
207
+
208
+ Validate map prevalence.
209
+
210
+ options:
211
+ -h, --help show this help message and exit
212
+ --collated_aoh_data COLLATED_DATA_PATH
213
+ CSV containing collated AoH data
214
+ --output OUTPUT_PATH CSV of outliers.
215
+ ```
216
+
217
+ This will produce a CSV file listing just the AoH maps that fail model validation.
218
+
219
+ **Note:** The validation tools require R to be installed on your system with the `lme4` and `lmerTest` packages.
@@ -0,0 +1,30 @@
1
+ """
2
+ AOH Calculator - A library for calculating Area of Habitat for species distribution mapping.
3
+
4
+ This package provides tools for:
5
+ - Calculating Area of Habitat from species range and habitat data
6
+ - Processing habitat data for species analysis
7
+ - Species richness and endemism calculations
8
+ - Validation of habitat maps
9
+ """
10
+
11
+ from pathlib import Path
12
+
13
+ import tomli as tomllib
14
+
15
+ from .cleaning import tidy_data
16
+
17
+ try:
18
+ from importlib import metadata
19
+ __version__: str = metadata.version(__name__)
20
+ except ModuleNotFoundError:
21
+ pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
22
+ with open(pyproject_path, "rb") as f:
23
+ pyproject_data = tomllib.load(f)
24
+ __version__ = pyproject_data["project"]["version"]
25
+
26
+ # Only export basic utilities by default
27
+ # Heavy dependencies are available via explicit imports
28
+ __all__ = [
29
+ "tidy_data"
30
+ ]