Skip to main content

The EASIER Data Initiative's Python Client

Features

  • Simple CID Data Retrieval
  • CID CSV To Dataframe Object
  • Querying EASIER STAC API by Bounding Box
    • Single Band Retrieval
    • Multi Band Retrieval

Installation

The client can be installed through pip

$ pip install ipfs-stac

Language Support

The client currently supports Python versions 3+

Usage

Create a client object

from ipfs_stac import client

# Create a new client object
easier = client.web3(local_gateway="", stac_endpoint="")

# If you want to force using a local node, specify the endpoint in the local_gateway argument
easier = client.web3(local_gateway="http://127.0.0.1:8000", stac_endpoint="")

Fetch a CID from IPFS

# Simple hello world example
data = easier.getFromCID("QmZ4tDuvesekSs4qM5ZBKpXiZGun7S2CYtEZRB3DYXkjGx")
print(data)

"""
hello worlds
"""

Get CID CSV Data to Pandas Dataframe

df = easier.getCSVDataframeFromCID("bafybeifw6kcodgxnamtuvhkxgaf4ep2rwscjae3gnzxb3zj5c6zyea2nri")
print(f"Data frame length: {len(df)}")

"""
Data frame length: 3510
"""

Query STAC API By Bounding Box

easier = client.web3(local_gateway="", stac="<YOUR STAC ENDPOINT GOES HERE>")
"""
Retrieve all items from STAC catalog that are in bounding box with searchSTACByBox method (2 arguments)
1. Coordinates of bounding box
2. Name(s) of STAC collections)
"""
items = easier.searchSTACByBox([-76.964657, 38.978967, -76.928008, 39.002783], ["<STAC COLLECTION GOES HERE>"])

"""
The searchSTACByBoxIndex by method takes 3 arguments
1. Coordinates for the bounding box
2. Name of the STAC collection to query
3. Index of the item you want to retrieve
"""
item = easier.searchSTACByBoxIndex([-76.964657, 38.978967, -76.928008, 39.002783], ["<STAC COLLECTION GOES HERE>"], 0)
band = easier.getAssetFromItem(item, 'ASSET NAME GOES HERE') # Returns asset object

# Optionally, you can fetch multiple assets by the getBandsFromItem Method
bands = easier.getAssetsFromItem(item, ["blue", "red"]) # Returns array of assets

The asset object

# This snippet extends the previous under "Query STAC API By Bounding Box"

# The asset object, when printed, will return the CID
print(band) # QmNddx9BvBsQMXgwp6a83D2wiLrmovgCpRKVYKSJoWNNbx

# You can fetch the asset bytes through the fetch method
data = band.fetch()

# Alternatively, you can fetch the asset as an np array
asset_array = band.fetchNPArray()

Attributions

This project was made possible by the following

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipfs_stac-0.1.7.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipfs_stac-0.1.7-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file ipfs_stac-0.1.7.tar.gz.

File metadata

  • Download URL: ipfs_stac-0.1.7.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ipfs_stac-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e482f9f2b592e6ec76081387df6f9129b31d5861660cf4ae05a445220f968506
MD5 f0f6ca30a02e92214735143622c1d7ff
BLAKE2b-256 e40e316f9d75cfa740c5433a241f343622d600fa0ea5b6621590d6cc4d83c166

See more details on using hashes here.

File details

Details for the file ipfs_stac-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: ipfs_stac-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ipfs_stac-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 67122193d7f21ce869f2260f6ef2d08a64c4c57f5910bed396304c2233711b7b
MD5 3dcc05beb295c79dcd0880a6c87b1253
BLAKE2b-256 d053e575318596176b9fb77ed56989290bf82e549b4d6dd31a1d2cc06bc4da9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page