User Guide#
This guide describes all available pyGuidos analysis tools. Each tool operates on a single-band uint8 GeoTIFF input and returns a result object containing statistics and optionally the output array.
Before using any tool, please read the Input Format page which describes the expected pixel value conventions and the GTB output format.
Available Tools#
The easiest way to explore the available tools and access their
scientific documentation is to use the interactive info() function:
import pyguidos as pg
# List all available analytical tools
pg.info()
# Get detailed links and usage for a specific tool
pg.info('mspa')
# Get full technical specification of a function
help(pg.mspa)
Function |
Description |
Output Files |
|---|---|---|
Morphology |
Morphological Spatial Pattern Analysis |
|
Fragmentation analysis |
|
|
Landscape Mosaic |
|
|
Patch Size Accounting |
|
|
Restoration Status Summary |
|
|
Extract raster by polygon features |
one |
Common Parameters#
All analysis functions share a common set of parameters:
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
str or Path |
– |
Path to input GeoTIFF |
|
str or Path |
None |
Output directory. Defaults to input file directory |
|
bool |
True |
Compute and return statistics |
|
bool |
True |
Write statistics to output files (.txt, .png, …) |
|
bool |
False |
Include output numpy array in result object |
|
bool |
False |
Print progress messages to stdout |
Result Objects#
Each analysis function returns a result dataclass with two fields:
stats: nested dictionary with three keys:
'output paths': paths to generated output files, orNoneifstat_files=False'input stats': pixel counts for the input map'output stats': tool-specific metrics and per-class pixel counts
array: the output numpy array, only populated when
return_array=True, otherwiseNone
import pyguidos as pg
result = pg.mspa("my_map.tif", edge_width=1)
# Access statistics dictionary
print(result.stats.keys())
# dict_keys(['output paths', 'input stats', 'output stats'])
# Access output array (requires return_array=True)
print(result.array)
# Access a specific output path
tif_path = result.stats['output paths']['path tif']
print(f"Result saved at: {tif_path}")
Standalone Statistics#
All tools provide a companion *_stats() function that can be called
independently on a previously generated output GeoTIFF, without
rerunning the full analysis:
# Recompute statistics on an existing MSPA output
stats = pg.mspa_stats(
mspa_tiff="output/my_map_mspa_8_1_1_1.tif",
outfile=True,
source_tiff="my_map.tif"
)
Note
Standalone *_stats() functions require as input raster files to
be output GeoTIFFs from pyGuidos or GTB. See Input Format for details.