satfarm


Namesatfarm JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA Python package for satellite image processing with fluent interface
upload_time2025-08-18 04:40:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords geospatial image processing raster remote sensing satellite
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # satfarm

[![PyPI version](https://badge.fury.io/py/satfarm.svg)](https://badge.fury.io/py/satfarm)
[![Python versions](https://img.shields.io/pypi/pyversions/satfarm.svg)](https://pypi.org/project/satfarm/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A Python package for satellite image processing with a fluent interface, built on top of rasterio and xarray.

## 🌟 Features

- **Raster data I/O**: Support for GeoTIFF, PNG, and other common formats
- **Coordinate reference system**: Transformation and resampling capabilities  
- **Band operations**: Spectral index calculations and band manipulations
- **Image rendering**: Visualization with customizable color maps
- **Geometric operations**: Clipping, shrinking, and spatial transformations
- **Fluent interface**: Chain operations together for readable, maintainable code

## 📦 Installation

```bash
pip install satfarm
```

### Development Installation

```bash
git clone https://github.com/yourusername/satfarm.git
cd satfarm
pip install -e ".[dev]"
```

## 🚀 Quick Start

```python
from satfarm import SatImage
import numpy as np

# Basic usage
processor = SatImage()

# Load and process satellite imagery
result = (processor
    .read_tif("path/to/satellite_image.tif")
    .change_pixel_dtype("float32")
    .change_nodata(new_nodata=np.nan, old_nodata=0)
    .reproject("EPSG:4326")
    .shrink(distance=30)
    .set_band_alias(["red", "green", "blue", "nir"])
    .to_tif("processed_image.tif")
)

print(result)
```

## 📖 Examples

### Spectral Index Calculation

```python
from satfarm import SatImage

# Load image and set band aliases
simage = (SatImage()
    .read_tif("multispectral_image.tif")
    .set_band_alias(["blue", "green", "red", "nir"])
)

# Calculate vegetation indices
equations = {
    "NDVI": "(B[4] - B[3]) / (B[4] + B[3])",
    "NDRE": "(B[4] - B[2]) / (B[4] + B[2])",
    "SAVI": "1.5 * (B[4] - B[3]) / (B[4] + B[3] + 0.5)"
}

# Process multiple indices
index_images = list(simage.calculate_index(equations))

for idx_img in index_images:
    print(f"Index: {idx_img.get_band_alias()}")
    stats = idx_img.calculate_band_stats()
    print(f"Statistics: {stats}")
```

### Image Rendering and Visualization

```python
# Render index with custom colormap
rendered = (index_images[0]  # NDVI
    .render_index(vmin=0, vmax=1, cmap="viridis")
    .rescale(0.5)  # Reduce resolution by 50%
    .to_png("ndvi_visualization.png")
)
```

### Image Merging and Analysis

```python
# Merge multiple index images
merged = SatImage().merge(index_images)

# Get image boundary
boundary = merged.get_boundary()

# Calculate comprehensive statistics
stats = merged.calculate_band_stats()
```

## 🏗️ API Reference

### Core Class

#### `SatImage`

The main class providing a fluent interface for satellite image processing.

**Key Methods:**

- **I/O Operations**
  - `read_tif(path)`: Load GeoTIFF files
  - `to_tif(path)`: Save as GeoTIFF
  - `to_png(path)`: Save as PNG

- **Data Manipulation**
  - `change_pixel_dtype(dtype)`: Convert pixel data type
  - `change_nodata(new_nodata, old_nodata)`: Update nodata values
  - `reproject(crs)`: Reproject to different coordinate system
  - `rescale(factor)`: Resize image by scaling factor
  - `shrink(distance)`: Reduce image extent by specified distance

- **Band Operations**
  - `set_band_alias(aliases)`: Assign names to bands
  - `extract_band(bands)`: Select specific bands
  - `apply_scale_factor(factors)`: Apply scaling factors to bands
  - `calculate_index(equations)`: Compute spectral indices

- **Analysis**
  - `calculate_band_stats()`: Compute statistical metrics
  - `get_boundary()`: Extract image boundary geometry

- **Visualization**
  - `render_index(vmin, vmax, cmap)`: Render with color mapping

- **Utilities**
  - `copy()`: Create deep copy
  - `merge(images)`: Combine multiple images
  - `is_empty()`: Check if image data exists

## 🔧 Dependencies

- **numpy** (>=1.21.0): Numerical computing
- **rioxarray** (>=0.13.0): Rasterio integration with xarray
- **geopandas** (>=0.12.0): Geospatial data handling
- **Pillow** (>=9.0.0): Image processing
- **matplotlib** (>=3.5.0): Plotting and visualization
- **typeguard** (>=4.0.0): Runtime type checking

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the project
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

- Built on top of the excellent [rasterio](https://rasterio.readthedocs.io/) and [xarray](https://xarray.pydata.org/) libraries
- Inspired by modern geospatial processing workflows
- Thanks to the open source geospatial community

## 📞 Support

If you encounter any issues or have questions, please [open an issue](https://github.com/yourusername/satfarm/issues) on GitHub.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "satfarm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "husgbb <hangm0101@gmail.com>",
    "keywords": "geospatial, image processing, raster, remote sensing, satellite",
    "author": null,
    "author_email": "husgbb <hangm0101@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/db/9c/52be0c4db965c2780c9bbc07e502a239c01cb6bbbd8b338b6d65404dcff1/satfarm-0.1.1.tar.gz",
    "platform": null,
    "description": "# satfarm\n\n[![PyPI version](https://badge.fury.io/py/satfarm.svg)](https://badge.fury.io/py/satfarm)\n[![Python versions](https://img.shields.io/pypi/pyversions/satfarm.svg)](https://pypi.org/project/satfarm/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Python package for satellite image processing with a fluent interface, built on top of rasterio and xarray.\n\n## \ud83c\udf1f Features\n\n- **Raster data I/O**: Support for GeoTIFF, PNG, and other common formats\n- **Coordinate reference system**: Transformation and resampling capabilities  \n- **Band operations**: Spectral index calculations and band manipulations\n- **Image rendering**: Visualization with customizable color maps\n- **Geometric operations**: Clipping, shrinking, and spatial transformations\n- **Fluent interface**: Chain operations together for readable, maintainable code\n\n## \ud83d\udce6 Installation\n\n```bash\npip install satfarm\n```\n\n### Development Installation\n\n```bash\ngit clone https://github.com/yourusername/satfarm.git\ncd satfarm\npip install -e \".[dev]\"\n```\n\n## \ud83d\ude80 Quick Start\n\n```python\nfrom satfarm import SatImage\nimport numpy as np\n\n# Basic usage\nprocessor = SatImage()\n\n# Load and process satellite imagery\nresult = (processor\n    .read_tif(\"path/to/satellite_image.tif\")\n    .change_pixel_dtype(\"float32\")\n    .change_nodata(new_nodata=np.nan, old_nodata=0)\n    .reproject(\"EPSG:4326\")\n    .shrink(distance=30)\n    .set_band_alias([\"red\", \"green\", \"blue\", \"nir\"])\n    .to_tif(\"processed_image.tif\")\n)\n\nprint(result)\n```\n\n## \ud83d\udcd6 Examples\n\n### Spectral Index Calculation\n\n```python\nfrom satfarm import SatImage\n\n# Load image and set band aliases\nsimage = (SatImage()\n    .read_tif(\"multispectral_image.tif\")\n    .set_band_alias([\"blue\", \"green\", \"red\", \"nir\"])\n)\n\n# Calculate vegetation indices\nequations = {\n    \"NDVI\": \"(B[4] - B[3]) / (B[4] + B[3])\",\n    \"NDRE\": \"(B[4] - B[2]) / (B[4] + B[2])\",\n    \"SAVI\": \"1.5 * (B[4] - B[3]) / (B[4] + B[3] + 0.5)\"\n}\n\n# Process multiple indices\nindex_images = list(simage.calculate_index(equations))\n\nfor idx_img in index_images:\n    print(f\"Index: {idx_img.get_band_alias()}\")\n    stats = idx_img.calculate_band_stats()\n    print(f\"Statistics: {stats}\")\n```\n\n### Image Rendering and Visualization\n\n```python\n# Render index with custom colormap\nrendered = (index_images[0]  # NDVI\n    .render_index(vmin=0, vmax=1, cmap=\"viridis\")\n    .rescale(0.5)  # Reduce resolution by 50%\n    .to_png(\"ndvi_visualization.png\")\n)\n```\n\n### Image Merging and Analysis\n\n```python\n# Merge multiple index images\nmerged = SatImage().merge(index_images)\n\n# Get image boundary\nboundary = merged.get_boundary()\n\n# Calculate comprehensive statistics\nstats = merged.calculate_band_stats()\n```\n\n## \ud83c\udfd7\ufe0f API Reference\n\n### Core Class\n\n#### `SatImage`\n\nThe main class providing a fluent interface for satellite image processing.\n\n**Key Methods:**\n\n- **I/O Operations**\n  - `read_tif(path)`: Load GeoTIFF files\n  - `to_tif(path)`: Save as GeoTIFF\n  - `to_png(path)`: Save as PNG\n\n- **Data Manipulation**\n  - `change_pixel_dtype(dtype)`: Convert pixel data type\n  - `change_nodata(new_nodata, old_nodata)`: Update nodata values\n  - `reproject(crs)`: Reproject to different coordinate system\n  - `rescale(factor)`: Resize image by scaling factor\n  - `shrink(distance)`: Reduce image extent by specified distance\n\n- **Band Operations**\n  - `set_band_alias(aliases)`: Assign names to bands\n  - `extract_band(bands)`: Select specific bands\n  - `apply_scale_factor(factors)`: Apply scaling factors to bands\n  - `calculate_index(equations)`: Compute spectral indices\n\n- **Analysis**\n  - `calculate_band_stats()`: Compute statistical metrics\n  - `get_boundary()`: Extract image boundary geometry\n\n- **Visualization**\n  - `render_index(vmin, vmax, cmap)`: Render with color mapping\n\n- **Utilities**\n  - `copy()`: Create deep copy\n  - `merge(images)`: Combine multiple images\n  - `is_empty()`: Check if image data exists\n\n## \ud83d\udd27 Dependencies\n\n- **numpy** (>=1.21.0): Numerical computing\n- **rioxarray** (>=0.13.0): Rasterio integration with xarray\n- **geopandas** (>=0.12.0): Geospatial data handling\n- **Pillow** (>=9.0.0): Image processing\n- **matplotlib** (>=3.5.0): Plotting and visualization\n- **typeguard** (>=4.0.0): Runtime type checking\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the project\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\n- Built on top of the excellent [rasterio](https://rasterio.readthedocs.io/) and [xarray](https://xarray.pydata.org/) libraries\n- Inspired by modern geospatial processing workflows\n- Thanks to the open source geospatial community\n\n## \ud83d\udcde Support\n\nIf you encounter any issues or have questions, please [open an issue](https://github.com/yourusername/satfarm/issues) on GitHub.",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python package for satellite image processing with fluent interface",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://github.com/saefarm-satellite/satfarm",
        "Homepage": "https://github.com/saefarm-satellite/satfarm",
        "Issues": "https://github.com/saefarm-satellite/satfarm/issues",
        "Repository": "https://github.com/saefarm-satellite/satfarm"
    },
    "split_keywords": [
        "geospatial",
        " image processing",
        " raster",
        " remote sensing",
        " satellite"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b8e3c64ac9b9bb7b0881033fe41e85eaf70c7302b6ee5c13aedb11dc80e5ef7c",
                "md5": "2eb7bdfce166deaf58377298933c55ec",
                "sha256": "5bfd570c1934c6109d1aeb78641195a6d24947a04d9a05b8b321e71f897d1e42"
            },
            "downloads": -1,
            "filename": "satfarm-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2eb7bdfce166deaf58377298933c55ec",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 22753,
            "upload_time": "2025-08-18T04:40:16",
            "upload_time_iso_8601": "2025-08-18T04:40:16.774692Z",
            "url": "https://files.pythonhosted.org/packages/b8/e3/c64ac9b9bb7b0881033fe41e85eaf70c7302b6ee5c13aedb11dc80e5ef7c/satfarm-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "db9c52be0c4db965c2780c9bbc07e502a239c01cb6bbbd8b338b6d65404dcff1",
                "md5": "932257ccfb2c7ea715875c80b75877da",
                "sha256": "3c0b962fe86c59e0277b75f8901bec1db455079917db5b893a7b9bb05381a2d2"
            },
            "downloads": -1,
            "filename": "satfarm-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "932257ccfb2c7ea715875c80b75877da",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 17777,
            "upload_time": "2025-08-18T04:40:18",
            "upload_time_iso_8601": "2025-08-18T04:40:18.390830Z",
            "url": "https://files.pythonhosted.org/packages/db/9c/52be0c4db965c2780c9bbc07e502a239c01cb6bbbd8b338b6d65404dcff1/satfarm-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-18 04:40:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "saefarm-satellite",
    "github_project": "satfarm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "satfarm"
}
        
Elapsed time: 1.07510s