Skip to main content

A library for predicting the classes of landslides based on their topography

Project description

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 shapefile
  • dem_location: Path to the Digital Elevation Model (DEM) file
  • use_existing_dem: If True, use the provided DEM. If False, download a new DEM
  • include_interior_points: If True, include interior polygon points in feature extraction
  • label_column: Optional column name for landslide type labels
  • output_dir: Optional directory to save feature files
  • min_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 file
  • shp_path: Path to the landslide inventory shapefile to predict
  • dem_location: Path to the Digital Elevation Model (DEM) file
  • use_existing_dem: If True, use the provided DEM. If False, download a new DEM
  • include_interior_points: If True, include interior polygon points
  • optimized_features_path: Optional path to CSV with selected feature indices
  • min_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
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

landsifier-2.1.0.tar.gz (33.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

landsifier-2.1.0-py3-none-any.whl (24.7 kB view details)

Uploaded Python 3

File details

Details for the file landsifier-2.1.0.tar.gz.

File metadata

  • Download URL: landsifier-2.1.0.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for landsifier-2.1.0.tar.gz
Algorithm Hash digest
SHA256 e176070416b063db978782cb021aceb31d45fbb3e6db8fac124a10b76d1f756d
MD5 1667632c451c5db1b3c5d7b9cae08f2d
BLAKE2b-256 1a54db9675a13c53f4ea495b2d6c8de26df4b614c65a7b433586603071b671d1

See more details on using hashes here.

File details

Details for the file landsifier-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: landsifier-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for landsifier-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f06c3eb5269918146dc184e755aeddbded3460010b6318eadb7e8224848eeed4
MD5 2cbbdae0576fef573e296e6124f967bf
BLAKE2b-256 d630d1d1b106430fac429824da8f936151a2f73d9240e131a4e1333286addba6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page