Metadata-Version: 2.4
Name: Landsifier
Version: 2.1.0
Summary: A library for predicting the classes of landslides based on their topography
Author-email: Manan Kapoor <manank1997@gmail.com>, Kushanav Bhuyan <kushanav.bhuyan@phd.unipd.it>, Kamal Rana <kamalrana520@gmail.com>, Nico Schlauf <nicoschlauf1@gmail.com>
License: Copyright (c) 2018 The Python Packaging Authority
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Home, https://github.com/manank1997/Landsifier-V2.0.0/
Project-URL: Repository, https://github.com/manank1997/Landsifier-V2.0.0/
Classifier: Programming Language :: Python :: 3.8
Classifier: Operating System :: OS Independent
Requires-Python: <3.12,>=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: pillow
Requires-Dist: cloudpickle
Requires-Dist: giotto-tda
Requires-Dist: ipython
Requires-Dist: joblib
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: scipy
Requires-Dist: shapely
Requires-Dist: geopandas
Requires-Dist: utm
Requires-Dist: scikit-learn
Requires-Dist: pyproj
Requires-Dist: elevation
Requires-Dist: pandas
Requires-Dist: tqdm
Dynamic: license-file

# 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:

```bash
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:

```bash
pip install landsifier
```

### Verification

After installation, verify the package works:

```python
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

```python
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

```python
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

```python
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

```python
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
)
```
