Lightweight reader for raster files
Project description
georeader
Read data from rasters: very few dependencies, reads from cloud storage and lazy loading.
Install
# From pip
pip install georeader-spaceml
# From GitHub
pip install git+https://github.com/spaceml-org/georeader#egg=georeader
# Install with Google dependencies (to read objects from Google Cloud Storage or Google Earth Engine)
pip install git+https://github.com/spaceml-org/georeader#egg=georeader[google]
# Install with Planetary Computer requirements
pip install git+https://github.com/spaceml-org/georeader#egg=georeader[microsoftplanetary]
Getting started
# This snippet requires:
# pip install fsspec gcsfs google-cloud-storage
import os
os.environ["GS_NO_SIGN_REQUEST"] = "YES"
from georeader.readers import S2_SAFE_reader
from georeader import read
cords_read = (-104.394, 32.026) # long, lat
crs_cords = "EPSG:4326"
s2_safe_path = S2_SAFE_reader.s2_public_bucket_path("S2B_MSIL1C_20191008T173219_N0208_R055_T13SER_20191008T204555.SAFE")
s2obj = S2_SAFE_reader.s2loader(s2_safe_path,
out_res=10, bands=["B04","B03","B02"])
# copy to local avoids http errors specially when not using a Google project.
# This will only copy the bands set up above B04, B03 and B02
s2obj = s2obj.cache_product_to_local_dir(".")
# See also read.read_from_bounds, read.read_from_polygon for different ways of croping an image
data = read.read_from_center_coords(s2obj,cords_read, shape=(2040, 4040),
crs_center_coords=crs_cords)
data_memory = data.load() # this loads the data to memory
data_memory # GeoTensor object
>> Transform: | 10.00, 0.00, 537020.00|
| 0.00,-10.00, 3553680.00|
| 0.00, 0.00, 1.00|
Shape: (3, 2040, 4040)
Resolution: (10.0, 10.0)
Bounds: (537020.0, 3533280.0, 577420.0, 3553680.0)
CRS: EPSG:32613
fill_value_default: 0
In the .values
attribute we have the plain numpy array that we can plot with show
:
from rasterio.plot import show
show(data_memory.values/3500, transform=data_memory.transform)
Saving the GeoTensor
as a COG GeoTIFF:
from georeader.save import save_cog
# Supports writing in bucket location (e.g. gs://bucket-name/s2_crop.tif)
save_cog(data_memory, "s2_crop.tif", descriptions=s2obj.bands)
Tutorials
Sentinel-2:
- Reading Sentinel-2 images from the public Google bucket
- Explore metadata of Sentinel-2 object
- Query Sentinel-2 images over a location and time span, mosaic and plot them
Other:
- Tutorial to read overlapping tiles from a GeoTIFF and a Sentinel-2 image
- Example of reading a Proba-V image overlapping with Sentinel-2 forcing same resolution
- Work with EMIT images
- Read high resolution tile layers
Used in other projects:
- georeader with ml4floods to automatically download and produce flood extent maps
- georeader with STARCOP to simulate Sentinel-2 from AVIRIS images
Citation
If you find this code useful please cite:
@article{portales-julia_global_2023,
title = {Global flood extent segmentation in optical satellite images},
volume = {13},
issn = {2045-2322},
doi = {10.1038/s41598-023-47595-7},
number = {1},
urldate = {2023-11-30},
journal = {Scientific Reports},
author = {Portalés-Julià, Enrique and Mateo-García, Gonzalo and Purcell, Cormac and Gómez-Chova, Luis},
month = nov,
year = {2023},
pages = {20316},
}
@article{ruzicka_starcop_2023,
title = {Semantic segmentation of methane plumes with hyperspectral machine learning models},
volume = {13},
issn = {2045-2322},
url = {https://www.nature.com/articles/s41598-023-44918-6},
doi = {10.1038/s41598-023-44918-6},
number = {1},
journal = {Scientific Reports},
author = {Růžička, Vít and Mateo-Garcia, Gonzalo and Gómez-Chova, Luis and Vaughan, Anna, and Guanter, Luis and Markham, Andrew},
month = nov,
year = {2023},
pages = {19999},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
georeader-spaceml-1.0.15.tar.gz
(134.2 kB
view details)
Built Distribution
File details
Details for the file georeader-spaceml-1.0.15.tar.gz
.
File metadata
- Download URL: georeader-spaceml-1.0.15.tar.gz
- Upload date:
- Size: 134.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9168751ed183c086dfa916c94dc2fa12190d59870e4cb5ec35e7574505b7282b |
|
MD5 | e62e7e1508e01f0a9ce14d4dda25a84a |
|
BLAKE2b-256 | 288da241d9bc714cb8935179c92f58d9876c8e459b005c3a335c2d1c2fa3f9e9 |
Provenance
File details
Details for the file georeader_spaceml-1.0.15-py3-none-any.whl
.
File metadata
- Download URL: georeader_spaceml-1.0.15-py3-none-any.whl
- Upload date:
- Size: 137.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1545f599afc8e38cd65ea605628fe4d9c71061c04fc7012c3b8a09167a027b6 |
|
MD5 | e069dcee66227986297e2efa9f4e1cf0 |
|
BLAKE2b-256 | d7c417953d794db774b96165b92bc804f86c859625b9491966ddffab96e8dff7 |