satcube


Namesatcube JSON
Version 0.1.18 PyPI version JSON
download
home_pagehttps://github.com/IPL-UV/satcube
SummaryA Python package to create cloud-free monthly composites by fusing Landsat and Sentinel-2 data.
upload_time2025-07-08 16:30:57
maintainerNone
docs_urlNone
authorCesar Aybar
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 

<p align="center">
  <img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/banner_satcube.png" width="33%">
</p>

<p align="center">
    <em>A Python package for managing Sentinel-2 satellite data cubes</em> 🚀
</p>

<p align="center">
<a href='https://pypi.python.org/pypi/satcube'>
    <img src='https://img.shields.io/pypi/v/satcube.svg' alt='PyPI' />
</a>
<a href="https://opensource.org/licenses/MIT" target="_blank">
    <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
</a>
<a href="https://github.com/psf/black" target="_blank">
    <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black">
</a>
<a href="https://pycqa.github.io/isort/" target="_blank">
    <img src="https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336" alt="isort">
</a>
</p>

---

**GitHub**: [https://github.com/IPL-UV/satcube](https://github.com/IPL-UV/satcube) 🌐

**PyPI**: [https://pypi.org/project/satcube/](https://pypi.org/project/satcube/) 🛠️

---

## **Overview** 📊

**satcube** is a Python package designed for efficient management, processing, and analysis of Sentinel-2 satellite image cubes. It allows for downloading, cloud masking, gap filling, and super-resolving Sentinel-2 imagery, as well as creating monthly composites and performing interpolation.

## **Key Features** ✨
- **Satellite image download**: Retrieve Sentinel-2 images from Earth Engine efficiently. 🛰️
- **Cloud masking**: Automatically remove clouds from Sentinel-2 images. ☁️
- **Gap filling**: Fill missing data using methods like linear interpolation and histogram matching. 🧩
- **Super-resolution**: Apply super-resolution models to enhance image quality. 🔍
- **Monthly composites**: Aggregate images into monthly composites with various statistical methods. 📅
- **Temporal smoothing**: Smooth reflectance values across time using interpolation techniques. 📈
## **Installation** ⚙️

Install the latest version from PyPI:

```bash
pip install satcube
```

## **How to use** 🛠️

### **Basic usage: working with sentinel-2 data** 🌍

#### **Load libraries**

```python
import ee
import satcube
```

#### **Authenticate and initialize earth engine**

```python
ee.Authenticate()
ee.Initialize(project="ee-csaybar-real")
```
#### **Download model weights**
```python
outpath = satcube.download_weights(path="weights")
```

#### **Create a satellite dataCube**
```python
datacube = satcube.SatCube(
    coordinates=(-77.68598590138802,-8.888223962022263),
    sensor=satcube.Sentinel2(weight_path=outpath, edge_size=384),
    output_dir="wendy01",
    max_workers=12,
    device="cuda",
)
```


### **Query and process sentinel-2 data** 🛰️

#### **Query the sentinel-2 image collection**

```python
# Query the Sentinel-2 image collection
table_query = datacube.metadata_s2()

# Filter images based on cloud cover and remove duplicates
table_query_subset = table_query[table_query["cs_cdf"] > 0.30]
table_query_subset = table_query_subset.drop_duplicates(subset="img_date")
mgrs_tile_max = table_query_subset["mgrs_title"].value_counts().idxmax()
table_query_subset = table_query_subset[table_query_subset["mgrs_title"] == mgrs_tile_max]
```

#### **Download sentinel-2 images**

```python
table_download = datacube.download_s2_image(table_query_subset)
```
#### **Cloud masking**

```python
# Remove clouds from the images
table_nocloud = datacube.cloudmasking_s2(table_download)
table_nocloud = table_nocloud[table_nocloud["cloud_cover"] < 0.75]
table_nocloud.reset_index(drop=True, inplace=True)
```

#### **Gap filling**

```python
# Fill missing data in the images
table_nogaps = datacube.gapfilling_s2(table_nocloud)
table_nogaps = table_nogaps[table_nogaps["match_error"] < 0.1]
```
### **Monthly composites and image smoothing 📅**

#### **Create monthly composites**

```python
# Generate monthly composites
table_composites = datacube.monthly_composites_s2(
    table_nogaps, agg_method="median", date_range=("2016-01-01", "2024-07-31")
)
```

#### **Interpolate missing data**

```python
# Interpolate missing months if necessary
table_interpolate = datacube.interpolate_s2(table=table_composites)
```

#### **Smooth reflectance values**

```python
# Smooth reflectance values across time
table_smooth = datacube.smooth_s2(table=table_interpolate)
```

### **Super-resolution and visualization** 📐



#### **Super-resolution**

```python
# Apply super-resolution to the image cube
# table_final = datacube.super_s2(table_smooth)
```


#### **Display images**

```python
# Display the images from the data cube
datacube.display_images(table=table_smooth)
```

#### **Create a GIF**

```python
# !apt-get install imagemagick
import os
os.system("convert -delay 20 -loop 0 wendy01/z_s2_07_smoothed_png/temp_07*.png animation.gif")

from IPython.display import Image
Image(filename='animation.gif', width=500)
```

<p align="center">
  <img src="https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/gif_satcube.gif" width="100%">
</p>

#### **Smooth reflectance values**

```python
# Smooth reflectance values across time
table_smooth = datacube.smooth_s2(table=table_interpolate)
```

## **Supported features and filters** ✨

- **Cloud masking:** Efficient removal of clouds from satellite images.
- **Resampling methods:** Various methods for resampling and aligning imagery.
- **Super-resolution:** ONNX-based models for improving image resolution.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/IPL-UV/satcube",
    "name": "satcube",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Cesar Aybar",
    "author_email": "fcesar.aybar@uv.es",
    "download_url": "https://files.pythonhosted.org/packages/d5/2f/b15a25d06d861402fb315fd063ea0db20365d75c6c21dcc2a65e05a56a65/satcube-0.1.18.tar.gz",
    "platform": null,
    "description": "# \n\n<p align=\"center\">\n  <img src=\"https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/banner_satcube.png\" width=\"33%\">\n</p>\n\n<p align=\"center\">\n    <em>A Python package for managing Sentinel-2 satellite data cubes</em> \ud83d\ude80\n</p>\n\n<p align=\"center\">\n<a href='https://pypi.python.org/pypi/satcube'>\n    <img src='https://img.shields.io/pypi/v/satcube.svg' alt='PyPI' />\n</a>\n<a href=\"https://opensource.org/licenses/MIT\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/License-MIT-blue.svg\" alt=\"License\">\n</a>\n<a href=\"https://github.com/psf/black\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/code%20style-black-000000.svg\" alt=\"Black\">\n</a>\n<a href=\"https://pycqa.github.io/isort/\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336\" alt=\"isort\">\n</a>\n</p>\n\n---\n\n**GitHub**: [https://github.com/IPL-UV/satcube](https://github.com/IPL-UV/satcube) \ud83c\udf10\n\n**PyPI**: [https://pypi.org/project/satcube/](https://pypi.org/project/satcube/) \ud83d\udee0\ufe0f\n\n---\n\n## **Overview** \ud83d\udcca\n\n**satcube** is a Python package designed for efficient management, processing, and analysis of Sentinel-2 satellite image cubes. It allows for downloading, cloud masking, gap filling, and super-resolving Sentinel-2 imagery, as well as creating monthly composites and performing interpolation.\n\n## **Key Features** \u2728\n- **Satellite image download**: Retrieve Sentinel-2 images from Earth Engine efficiently. \ud83d\udef0\ufe0f\n- **Cloud masking**: Automatically remove clouds from Sentinel-2 images. \u2601\ufe0f\n- **Gap filling**: Fill missing data using methods like linear interpolation and histogram matching. \ud83e\udde9\n- **Super-resolution**: Apply super-resolution models to enhance image quality. \ud83d\udd0d\n- **Monthly composites**: Aggregate images into monthly composites with various statistical methods. \ud83d\udcc5\n- **Temporal smoothing**: Smooth reflectance values across time using interpolation techniques. \ud83d\udcc8\n## **Installation** \u2699\ufe0f\n\nInstall the latest version from PyPI:\n\n```bash\npip install satcube\n```\n\n## **How to use** \ud83d\udee0\ufe0f\n\n### **Basic usage: working with sentinel-2 data** \ud83c\udf0d\n\n#### **Load libraries**\n\n```python\nimport ee\nimport satcube\n```\n\n#### **Authenticate and initialize earth engine**\n\n```python\nee.Authenticate()\nee.Initialize(project=\"ee-csaybar-real\")\n```\n#### **Download model weights**\n```python\noutpath = satcube.download_weights(path=\"weights\")\n```\n\n#### **Create a satellite dataCube**\n```python\ndatacube = satcube.SatCube(\n    coordinates=(-77.68598590138802,-8.888223962022263),\n    sensor=satcube.Sentinel2(weight_path=outpath, edge_size=384),\n    output_dir=\"wendy01\",\n    max_workers=12,\n    device=\"cuda\",\n)\n```\n\n\n### **Query and process sentinel-2 data** \ud83d\udef0\ufe0f\n\n#### **Query the sentinel-2 image collection**\n\n```python\n# Query the Sentinel-2 image collection\ntable_query = datacube.metadata_s2()\n\n# Filter images based on cloud cover and remove duplicates\ntable_query_subset = table_query[table_query[\"cs_cdf\"] > 0.30]\ntable_query_subset = table_query_subset.drop_duplicates(subset=\"img_date\")\nmgrs_tile_max = table_query_subset[\"mgrs_title\"].value_counts().idxmax()\ntable_query_subset = table_query_subset[table_query_subset[\"mgrs_title\"] == mgrs_tile_max]\n```\n\n#### **Download sentinel-2 images**\n\n```python\ntable_download = datacube.download_s2_image(table_query_subset)\n```\n#### **Cloud masking**\n\n```python\n# Remove clouds from the images\ntable_nocloud = datacube.cloudmasking_s2(table_download)\ntable_nocloud = table_nocloud[table_nocloud[\"cloud_cover\"] < 0.75]\ntable_nocloud.reset_index(drop=True, inplace=True)\n```\n\n#### **Gap filling**\n\n```python\n# Fill missing data in the images\ntable_nogaps = datacube.gapfilling_s2(table_nocloud)\ntable_nogaps = table_nogaps[table_nogaps[\"match_error\"] < 0.1]\n```\n### **Monthly composites and image smoothing \ud83d\udcc5**\n\n#### **Create monthly composites**\n\n```python\n# Generate monthly composites\ntable_composites = datacube.monthly_composites_s2(\n    table_nogaps, agg_method=\"median\", date_range=(\"2016-01-01\", \"2024-07-31\")\n)\n```\n\n#### **Interpolate missing data**\n\n```python\n# Interpolate missing months if necessary\ntable_interpolate = datacube.interpolate_s2(table=table_composites)\n```\n\n#### **Smooth reflectance values**\n\n```python\n# Smooth reflectance values across time\ntable_smooth = datacube.smooth_s2(table=table_interpolate)\n```\n\n### **Super-resolution and visualization** \ud83d\udcd0\n\n\n\n#### **Super-resolution**\n\n```python\n# Apply super-resolution to the image cube\n# table_final = datacube.super_s2(table_smooth)\n```\n\n\n#### **Display images**\n\n```python\n# Display the images from the data cube\ndatacube.display_images(table=table_smooth)\n```\n\n#### **Create a GIF**\n\n```python\n# !apt-get install imagemagick\nimport os\nos.system(\"convert -delay 20 -loop 0 wendy01/z_s2_07_smoothed_png/temp_07*.png animation.gif\")\n\nfrom IPython.display import Image\nImage(filename='animation.gif', width=500)\n```\n\n<p align=\"center\">\n  <img src=\"https://huggingface.co/datasets/JulioContrerasH/DataMLSTAC/resolve/main/gif_satcube.gif\" width=\"100%\">\n</p>\n\n#### **Smooth reflectance values**\n\n```python\n# Smooth reflectance values across time\ntable_smooth = datacube.smooth_s2(table=table_interpolate)\n```\n\n## **Supported features and filters** \u2728\n\n- **Cloud masking:** Efficient removal of clouds from satellite images.\n- **Resampling methods:** Various methods for resampling and aligning imagery.\n- **Super-resolution:** ONNX-based models for improving image resolution.",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python package to create cloud-free monthly composites by fusing Landsat and Sentinel-2 data.",
    "version": "0.1.18",
    "project_urls": {
        "Documentation": "https://ipl-uv.github.io/satcube/",
        "Homepage": "https://github.com/IPL-UV/satcube",
        "Repository": "https://github.com/IPL-UV/satcube"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f018e8fd091979c915c17ffa4115d1754371cfa1ee25a8e2f2e969de8f1ea95c",
                "md5": "daeba87849b336c790a0754e7bc430aa",
                "sha256": "959b8dd2adf01173b5e1a801d3a4c3e458a235c0fc7001f7433126d23f31b49d"
            },
            "downloads": -1,
            "filename": "satcube-0.1.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "daeba87849b336c790a0754e7bc430aa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 29455,
            "upload_time": "2025-07-08T16:30:56",
            "upload_time_iso_8601": "2025-07-08T16:30:56.384898Z",
            "url": "https://files.pythonhosted.org/packages/f0/18/e8fd091979c915c17ffa4115d1754371cfa1ee25a8e2f2e969de8f1ea95c/satcube-0.1.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d52fb15a25d06d861402fb315fd063ea0db20365d75c6c21dcc2a65e05a56a65",
                "md5": "d8592a12623e56261c70aca5d7e11cea",
                "sha256": "fd3fc9f1a79b3fe763d539225b4e372521537e4f3b3a33f3906ee6865ac3dbde"
            },
            "downloads": -1,
            "filename": "satcube-0.1.18.tar.gz",
            "has_sig": false,
            "md5_digest": "d8592a12623e56261c70aca5d7e11cea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 26452,
            "upload_time": "2025-07-08T16:30:57",
            "upload_time_iso_8601": "2025-07-08T16:30:57.999956Z",
            "url": "https://files.pythonhosted.org/packages/d5/2f/b15a25d06d861402fb315fd063ea0db20365d75c6c21dcc2a65e05a56a65/satcube-0.1.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-08 16:30:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "IPL-UV",
    "github_project": "satcube",
    "github_not_found": true,
    "lcname": "satcube"
}
        
Elapsed time: 1.26675s