Landsifier
A library for predicting the classes of landslides based on their topography using topological data analysis.
Installation
Windows (Recommended)
For Windows users, we recommend using Conda to avoid compilation issues with GDAL:
conda create -n landsifier python=3.11
conda activate landsifier
conda install -c conda-forge geopandas
pip install landsifier
Linux/macOS
Standard pip installation works on Linux and macOS:
pip install landsifier
Verification
After installation, verify the package works:
import landsifier
print(landsifier.__version__)
System Requirements
- GDAL: Required for geospatial operations. On Windows, install via
conda install -c conda-forge gdal. On Linux/macOS, pip will install it automatically through geopandas. - Python 3.8-3.11
Quick Start
Landsifier provides three main functions for the complete workflow:
1. Extract Features
from landsifier import extract_features
# Extract topological features from a landslide inventory
features = extract_features(
shp_path="path/to/inventory.shp",
dem_location="path/to/dem.tif",
use_existing_dem=True,
include_interior_points=False,
label_column="Type"
)
Parameters:
shp_path: Path to the landslide inventory shapefiledem_location: Path to the Digital Elevation Model (DEM) fileuse_existing_dem: If True, use the provided DEM. If False, download a new DEMinclude_interior_points: If True, include interior polygon points in feature extractionlabel_column: Optional column name for landslide type labelsoutput_dir: Optional directory to save feature filesmin_area_threshold: Minimum polygon area in m² (default: 500.0)
2. Train Classifier
from landsifier import train_classifier
# Train a Random Forest classifier on extracted features
trained_models = train_classifier(
path="path/to/directory/with/feature_files",
top_k=8 # Number of top features to use
)
Parameters:
path: Directory containing .npy feature files (one per class)top_k: Number of top features to select (default: 8)
Returns: A dictionary containing trained models and evaluation metrics.
3. Predict Inventory
from landsifier import predict_inventory
# Predict landslide types for new inventory
predicted_gdf = predict_inventory(
model_path="path/to/trained_model.pkl",
shp_path="path/to/new_inventory.shp",
dem_location="path/to/dem.tif",
use_existing_dem=True,
include_interior_points=False
)
Parameters:
model_path: Path to the pickled trained model fileshp_path: Path to the landslide inventory shapefile to predictdem_location: Path to the Digital Elevation Model (DEM) fileuse_existing_dem: If True, use the provided DEM. If False, download a new DEMinclude_interior_points: If True, include interior polygon pointsoptimized_features_path: Optional path to CSV with selected feature indicesmin_area_threshold: Minimum polygon area in m² (default: 500.0)
Returns: A GeoDataFrame with predicted landslide type labels.
Complete Workflow Example
from landsifier import extract_features, train_classifier, predict_inventory
# 1. Extract features from labeled training data
extract_features(
shp_path="training.shp",
dem_location="dem.tif",
use_existing_dem=True,
include_interior_points=False,
label_column="Type",
output_dir="features"
)
# 2. Train classifier
train_classifier(path="features")
# 3. Predict on new data
predictions = predict_inventory(
model_path="features/Model_All_Features.pkl",
shp_path="new_data.shp",
dem_location="new_dem.tif",
use_existing_dem=True,
include_interior_points=False
)
Metadata
Release files for Landsifier 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| landsifier-2.1.0.tar.gz | 33.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| landsifier-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.2 kB
Release files / landsifier-2.1.0.tar.gz
| Download URL | landsifier-2.1.0.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e176070416b063db978782cb021aceb31d45fbb3e6db8fac124a10b76d1f756d
|
|
BLAKE2b-256 checksum How to use checksums |
1a54db9675a13c53f4ea495b2d6c8de26df4b614c65a7b433586603071b671d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / landsifier-2.1.0-py3-none-any.whl
| Download URL | landsifier-2.1.0-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f06c3eb5269918146dc184e755aeddbded3460010b6318eadb7e8224848eeed4
|
|
BLAKE2b-256 checksum How to use checksums |
d630d1d1b106430fac429824da8f936151a2f73d9240e131a4e1333286addba6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|