Make web requests to a ResonantGeoData instance.
Project description
rgd_client - ResonantGeoDataClient
The rgd_client Python package allows users to make web requests to a ResonantGeoData instance within a Python script.
Installation
pip install rgd-client
Usage
Search and display results
import json
import matplotlib.pyplot as plt
import numpy as np
from rgd_client import Rgdc
def plot_geojson(gjs, *args, **kwargs):
points = np.array(gjs['coordinates'][0])
return plt.plot(points[:,0], points[:,1], *args, **kwargs)
client = Rgdc(username='username', password='password')
bbox = {
"type":"Polygon",
"coordinates":[
[
[-105.45091240368326,39.626245373878696],
[-105.45091240368326,39.929904289147274],
[-104.88775649170178,39.929904289147274],
[-104.88775649170178,39.626245373878696],
[-105.45091240368326,39.626245373878696]
]
]
}
q = client.search(query=json.dumps(bbox), predicate='intersects')
for s in q:
print(s['subentry_name'])
plot_geojson(bbox, 'k--', label='Search Region')
for s in q:
plot_geojson(s['footprint'], label=s['subentry_name'])
plt.legend()
plt.title(f'Count: {len(q)}')
Inspect raster
import imageio
from io import BytesIO
import requests
raster = requests.get(q[0]['detail']).json()
plot_geojson(bbox, 'k--')
plot_geojson(raster['outline'], 'r')
load_image = lambda imbytes: imageio.imread(BytesIO(imbytes))
count = len(raster['parent_raster']['image_set']['images'])
for i in range(count):
thumb_bytes = client.download_raster_thumbnail(q[0], band=i)
thumb = load_image(thumb_bytes)
plt.subplot(1, count, i+1)
plt.imshow(thumb)
plt.tight_layout()
plt.show()
Download Raster
import rasterio
from rasterio.plot import show
paths = client.download_raster(q[0])
rasters = [rasterio.open(im) for im in paths.images]
for i, src in enumerate(rasters):
plt.subplot(1, count, i+1)
ax = plt.gca()
show(src, ax=ax)
plt.tight_layout()
plt.show()
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
rgd-client-0.2.0rc8.tar.gz
(9.5 kB
view details)
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 rgd-client-0.2.0rc8.tar.gz.
File metadata
- Download URL: rgd-client-0.2.0rc8.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b72f4587f8047322731404eb32bf74d0825cf83f12ad3c28618aad90474b21e
|
|
| MD5 |
aef1cf07b7e1da74286abe983b3bb697
|
|
| BLAKE2b-256 |
28ede081340168c983f576008619e135018e73f7f8cca5119ff448008f680ed0
|
File details
Details for the file rgd_client-0.2.0rc8-py3-none-any.whl.
File metadata
- Download URL: rgd_client-0.2.0rc8-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8086c498e6a43bb77130c415ac899bbe022045f9f88e8e973980e18c6d436474
|
|
| MD5 |
7a9c09df5ab08f836c7f116037cdec96
|
|
| BLAKE2b-256 |
3e04d9bbcb7bac5d00a42e05a54723a69cf7fcb0ce605e5aa468a7b2899be6f4
|