Query and access Microsoft Planetary Computer Data Catalogs using geopandas and xarray.
Project description
pcxarray
A Python package for easy querying and access to Microsoft Planetary Computer Data Catalogs using geopandas and xarray.
Features
- Query Microsoft Planetary Computer STAC API using shapely geometries
- Retrieve results as GeoDataFrames for easy inspection and filtering
- Download and preprocess raster data into xarray DataArrays
- Utilities for creating spatial grids and loading US Census TIGER shapefiles
Installation
pcxarray can be installed via pip.
python -m pip install pcxarray
Alternatively, you can install the development version directly from GitHub:
git clone https://github.com/gcermsu/pcxarray
cd pcxarray
python -m pip install -e ".[dev]"
Usage
See naip_demo.ipynb for a complete example of querying NAIP imagery.
from pcxarray import pc_query, prepare_data, query_and_prepare
from pcxarray.utils import create_grid, load_census_shapefile
# Load US state boundaries
states_gdf = load_census_shapefile(level="state")
# Select a state (e.g., Mississippi)
ms_gdf = states_gdf[states_gdf['STUSPS'] == 'MS']
ms_gdf = ms_gdf.to_crs(epsg=3814) # Reproject to a projected CRS (e.g., EPSG:3814 for Mississippi)
# Create a grid over the state
grid_gdf = create_grid(
ms_gdf.iloc[0].geometry,
crs=ms_gdf.crs,
cell_size=1000 # each cell will be 1000 meters square (units depend on the CRS)
)
selected_geom = grid_gdf.iloc[10000].geometry # Select a single geometry for demonstration
# Query NAIP imagery for a grid cell
items_gdf = pc_query(
collections='naip',
geometry=selected_geom,
crs=grid_gdf.crs,
datetime='2023'
)
# Download and load NAIP data as an xarray DataArray - imagery is clipped to the
# geometry of the given geometry, and a mosaic is created if the geometry spans
# multiple indiviudual items.
imagery = prepare_data(
geometry=selected_geom,
crs=grid_gdf.crs,
items_gdf=items_gdf,
target_resolution=1.0
)
# Or combine query and load in one step
imagery = query_and_prepare(
collections='naip',
geometry=selected_geom,
crs=grid_gdf.crs,
datetime='2023',
target_resolution=1.0
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcxarray-0.1.1.tar.gz.
File metadata
- Download URL: pcxarray-0.1.1.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c0a691fa92abebe5407e519d359371d179a72da0c7adf4d80e4c17cf7c7d2a1
|
|
| MD5 |
cedb62539c2f8f1c87e6e19e8f3f0edc
|
|
| BLAKE2b-256 |
00abec6c6bfe9c7df4d9eb45e2fd0f171982e14fd7c1852df1843c20f98bd95b
|
File details
Details for the file pcxarray-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pcxarray-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ff0b3226a75a5e42a2d7300ae93362b3755b62c2f56c5cd7df686f776e5b56a
|
|
| MD5 |
f16284155a7607607b6aaad732a41bbe
|
|
| BLAKE2b-256 |
9ca8737357d3cbf530d7f39f7cf3ba2d75c971787f2c59ce8e34bae72b5c3f1b
|