Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stac reader #70

Merged
merged 30 commits into from
Sep 26, 2020
Merged

stac reader #70

merged 30 commits into from
Sep 26, 2020

Conversation

geospatial-jeff
Copy link
Owner

@geospatial-jeff geospatial-jeff commented Sep 14, 2020

Closes #69

This PR adds a CompositeReader which allows performing the same operation over multiple COGReader instances via MapReduce. Composite readers implement the same interface as a normal reader (enforced through the ReaderMixin class). Also add the STACReader which extends CompositeReader.

The caller can easily implement their own filter/map/reduce functions, for example calculating ndvi from an naip stac item:

import asyncio
import os

os.environ['AWS_REQUEST_PAYER'] = "requester"

from aiocogeo.stac import STACReader
from stac_pydantic.shared import MimeTypes

def ndvi(arr):
    arr = arr[0]
    return (arr[3] - arr[1]) / (arr[3] + arr[1])

async def main():
    async with STACReader(
        filepath="http://stac.arturo.ai/collections/naip/items/m_3311717_nw_11_060_20180723",
        include_types={MimeTypes.cog}, # Only try to read COG types
        filter=lambda a: a.asset.name == "analytic_cog" # Filter for the asset with NIR band
    ) as reader:
        val = await reader.point(
            x=412382.1,
            y=3731494.7,
            reducer=ndvi
        )
        print(val)


asyncio.run(main())

>>> 0.35686275

@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2020

Codecov Report

Merging #70 into master will decrease coverage by 3.22%.
The diff coverage is 73.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
- Coverage   94.69%   91.46%   -3.23%     
==========================================
  Files          12       13       +1     
  Lines         886     1043     +157     
==========================================
+ Hits          839      954     +115     
- Misses         47       89      +42     
Impacted Files Coverage Δ
aiocogeo/filesystems.py 82.69% <35.13%> (-10.38%) ⬇️
aiocogeo/tiler.py 80.73% <70.27%> (-5.94%) ⬇️
aiocogeo/cog.py 94.25% <85.18%> (-3.20%) ⬇️
aiocogeo/errors.py 100.00% <100.00%> (ø)
aiocogeo/stac.py 100.00% <100.00%> (ø)
aiocogeo/partial_reads.py 96.00% <0.00%> (+0.57%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76b064d...caae839. Read the comment docs.

@geospatial-jeff geospatial-jeff merged commit 2c5243f into master Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add STAC filesystem
2 participants