izisat 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- izisat/__init__.py +0 -0
- izisat/izisentinel.py +161 -0
- izisat/misc/__init__.py +0 -0
- izisat/misc/connections.py +554 -0
- izisat/misc/dates.py +24 -0
- izisat/misc/files.py +135 -0
- izisat/misc/raster_processing.py +373 -0
- izisat/misc/utils.py +162 -0
- izisat-0.1.0.dist-info/METADATA +151 -0
- izisat-0.1.0.dist-info/RECORD +13 -0
- izisat-0.1.0.dist-info/WHEEL +5 -0
- izisat-0.1.0.dist-info/licenses/LICENSE +21 -0
- izisat-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: izisat
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Add your description here
|
5
|
+
Requires-Python: >=3.12
|
6
|
+
Description-Content-Type: text/markdown
|
7
|
+
License-File: LICENSE
|
8
|
+
Requires-Dist: geopandas>=1.1.1
|
9
|
+
Requires-Dist: loguru>=0.7.3
|
10
|
+
Requires-Dist: requests>=2.32.4
|
11
|
+
Requires-Dist: tqdm>=4.67.1
|
12
|
+
Dynamic: license-file
|
13
|
+
|
14
|
+
# izisat
|
15
|
+
|
16
|
+
`izisat` is a Python library designed to facilitate the automated download of Sentinel-2 satellite imagery bands from the Copernicus Open Access Hub (previously SciHub). It provides functionalities to connect to the Copernicus API, construct queries based on geographical footprints and time ranges, retrieve product information, and download specified bands to a local directory structure.
|
17
|
+
|
18
|
+
## Features
|
19
|
+
|
20
|
+
* **API Connection:** Securely connect to the Copernicus Open Access Hub using provided credentials.
|
21
|
+
* **Query Construction:** Build complex queries for Sentinel-2 products based on:
|
22
|
+
* Geographical footprint (WKT format)
|
23
|
+
* Start and End Dates
|
24
|
+
* Cloud Cover Percentage
|
25
|
+
* Product Type (e.g., L2A)
|
26
|
+
* Platform Name (e.g., SENTINEL-2)
|
27
|
+
* **Product Retrieval:** Fetch a list of available Sentinel-2 products matching the constructed query.
|
28
|
+
* **Automated Folder Creation:** Organize downloaded bands into a structured directory based on product information (e.g., `auxiliary/Sentinel-2/YYYY/MM/DD/TILE/L2A/RESOLUTION/`).
|
29
|
+
* **Band Downloading:** Download specific Sentinel-2 bands (e.g., B02, B03, B04, B08) for retrieved products.
|
30
|
+
|
31
|
+
## Installation
|
32
|
+
|
33
|
+
*(Placeholder: Add installation instructions here, e.g., using pip and a `requirements.txt` or `pyproject.toml`)*
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
The `IZISentinel` class is the main entry point for interacting with the library. Below is an example demonstrating how to use `izisat` to download Sentinel-2 bands.
|
38
|
+
|
39
|
+
```python
|
40
|
+
import geopandas as gpd
|
41
|
+
from datetime import datetime, timedelta
|
42
|
+
from izisat.izisentinel import IZISentinel
|
43
|
+
|
44
|
+
# Configuration
|
45
|
+
DOWNLOAD_FOLDER = '/home/ppz/Documentos/coding/izisat/auxiliary' # Adjust as needed
|
46
|
+
MAX_CLOUD_COVER = 99
|
47
|
+
BANDS_DICT = {"L2A":{"10m": ["B02", "B03","B04", "B08"]}} # Specify bands and resolutions
|
48
|
+
PLATFORM_NAME = "SENTINEL-2"
|
49
|
+
SATELLITE_TYPE = 'L2A' # Level 2A products (bottom-of-atmosphere corrected)
|
50
|
+
COPERNICUS_USER='your_copernicus_username' # Replace with your Copernicus username
|
51
|
+
COPERNICUS_PASSWD='your_copernicus_password' # Replace with your Copernicus password
|
52
|
+
|
53
|
+
# Define date range
|
54
|
+
today = datetime.now().strftime('%Y-%m-%d')
|
55
|
+
one_week_ago = (datetime.now() - timedelta(days=7)).strftime('%Y-%m-%d')
|
56
|
+
|
57
|
+
# Initialize the downloader
|
58
|
+
downloader = IZISentinel(output_base_path=DOWNLOAD_FOLDER)
|
59
|
+
|
60
|
+
# 1. Connect to Copernicus API
|
61
|
+
access_token, refresh_token, dt_access_token = downloader.connect_to_api(
|
62
|
+
username=COPERNICUS_USER,
|
63
|
+
password=COPERNICUS_PASSWD
|
64
|
+
)
|
65
|
+
|
66
|
+
# 2. Load geographical footprint (example using a GeoJSON file)
|
67
|
+
# Replace 'path/to/your/farm.geojson' with the actual path to your GeoJSON file
|
68
|
+
# The GeoJSON should contain a polygon representing your area of interest.
|
69
|
+
try:
|
70
|
+
farm = gpd.read_file('/home/ppz/Documentos/coding/forestry_monitor/data/vectors/farms/farms.geojson')
|
71
|
+
footprint = farm.iloc[0].geometry.wkt # Assuming the first feature's geometry is the desired footprint
|
72
|
+
except Exception as e:
|
73
|
+
print(f"Error loading GeoJSON or extracting footprint: {e}")
|
74
|
+
print("Please ensure 'forestry_monitor/data/vectors/farms/farms.geojson' exists and is valid, or provide a WKT string directly.")
|
75
|
+
footprint = "POLYGON ((<lon1> <lat1>, <lon2> <lat2>, ...))" # Example placeholder for direct WKT
|
76
|
+
|
77
|
+
# 3. Construct the query
|
78
|
+
query = downloader.construct_query(
|
79
|
+
footprint=footprint,
|
80
|
+
end_date=today,
|
81
|
+
start_date=one_week_ago,
|
82
|
+
cloud_cover_percentage=MAX_CLOUD_COVER,
|
83
|
+
type=SATELLITE_TYPE,
|
84
|
+
platform_name=PLATFORM_NAME
|
85
|
+
)
|
86
|
+
|
87
|
+
# 4. Retrieve products
|
88
|
+
products = downloader.products_from_sentinel_2(query)
|
89
|
+
|
90
|
+
# 5. Download specified bands
|
91
|
+
if products:
|
92
|
+
images_downloaded = downloader.download_sentinel2_bands(
|
93
|
+
access_token,
|
94
|
+
products,
|
95
|
+
BANDS_DICT,
|
96
|
+
dt_access_token,
|
97
|
+
refresh_token,
|
98
|
+
tile=None # Specify a tile if you want to filter by tile, otherwise None
|
99
|
+
)
|
100
|
+
print(f"Downloaded images info: {images_downloaded}")
|
101
|
+
else:
|
102
|
+
print("No products found for the given query.")
|
103
|
+
```
|
104
|
+
|
105
|
+
## Dependencies
|
106
|
+
|
107
|
+
The core dependencies for `izisat` include:
|
108
|
+
|
109
|
+
* `loguru`: For logging.
|
110
|
+
* `geopandas`: For handling geographical data (used in the example for footprint).
|
111
|
+
* `datetime`: For date and time operations.
|
112
|
+
|
113
|
+
*(Note: Specific versions and other implicit dependencies from `izisat.misc` modules would be listed in `pyproject.toml` or `requirements.txt`)*
|
114
|
+
|
115
|
+
## Project Structure
|
116
|
+
|
117
|
+
```
|
118
|
+
.
|
119
|
+
├── auxiliary/
|
120
|
+
│ └── Sentinel-2/ # Default download location for Sentinel-2 bands
|
121
|
+
├── src/
|
122
|
+
│ └── izisat/
|
123
|
+
│ ├── __init__.py
|
124
|
+
│ ├── izisentinel.py # Main class for Sentinel-2 band downloading
|
125
|
+
│ └── misc/
|
126
|
+
│ ├── __init__.py
|
127
|
+
│ ├── connections.py # Handles API connections to Copernicus
|
128
|
+
│ ├── dates.py # Utility functions for date handling
|
129
|
+
│ ├── files.py # Utility functions for file and directory operations
|
130
|
+
│ └── utils.py # General utility functions (e.g., query construction, product info retrieval)
|
131
|
+
├── .gitignore
|
132
|
+
├── LICENSE
|
133
|
+
├── pyproject.toml
|
134
|
+
├── README.md
|
135
|
+
└── uv.lock
|
136
|
+
```
|
137
|
+
|
138
|
+
## How to Contribute
|
139
|
+
|
140
|
+
We welcome contributions to `izisat`! If you'd like to contribute, please follow these guidelines:
|
141
|
+
|
142
|
+
1. **Reporting Bugs:** If you find a bug, please open an issue on the GitHub repository. Provide a clear and concise description of the bug, steps to reproduce it, and expected behavior.
|
143
|
+
2. **Suggesting Features:** For new features or enhancements, open an issue to discuss your ideas.
|
144
|
+
3. **Submitting Pull Requests:**
|
145
|
+
* Fork the repository and create a new branch for your changes.
|
146
|
+
* Ensure your code adheres to the project's coding style.
|
147
|
+
* Write clear and concise commit messages.
|
148
|
+
* Include tests for new features or bug fixes.
|
149
|
+
* Submit a pull request with a detailed description of your changes.
|
150
|
+
|
151
|
+
Thank you for your contributions!
|
@@ -0,0 +1,13 @@
|
|
1
|
+
izisat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
izisat/izisentinel.py,sha256=y79dPkiQgux7m1yxiTyC4wzdfn7V5e7JKDCLmEWOeiw,8440
|
3
|
+
izisat/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
izisat/misc/connections.py,sha256=_P_HyHZPpc46kYp0MjdRQZWYMrM-9Fn_nmwQWhfscoI,24424
|
5
|
+
izisat/misc/dates.py,sha256=Px0o2LBz48mVmoJj-v4PyYmwPT3W__oWmlhS4P5q4DQ,681
|
6
|
+
izisat/misc/files.py,sha256=rb_36HqUuy4nQr6U9X-OwdX5rxKUyca9-nvo7KmvsR4,5103
|
7
|
+
izisat/misc/raster_processing.py,sha256=DuzCmi4eykIn7t-SRBWQDSpEgzp6-OTg_GqkOQ7eItk,13745
|
8
|
+
izisat/misc/utils.py,sha256=ZCQtE8NH5bJyLmMVZ4ds9zWRAzae3EDMVe0plIv8TQ8,7924
|
9
|
+
izisat-0.1.0.dist-info/licenses/LICENSE,sha256=aDkQU04Ctm_SV6RJcRpMTAXxtOTvAORT52Swc_Vgh7c,1072
|
10
|
+
izisat-0.1.0.dist-info/METADATA,sha256=sENs-iODIJudVX5AleUISyIIT0AW-3yw7YbHZl3DrXY,6272
|
11
|
+
izisat-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
+
izisat-0.1.0.dist-info/top_level.txt,sha256=8pyYezZfRdKFuqZv_ZCxgRUJbpi6C0KuwMSlAa5Wbrc,7
|
13
|
+
izisat-0.1.0.dist-info/RECORD,,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 anderson stolfi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
izisat
|