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

fix Earthdata example (almost?) #15

Conversation

gaelforget
Copy link
Member

It seems that requests to https://cmr.earthdata.nasa.gov/search/granules.stac now require that the url includes a collection_concept_id. The modification to src/search.jl does this and allows for an empty query specification.

In the example, the handling of url, query v FeatureCollection also needed an update after 918a1a9 I believe.

Some problems that may remain :

  • [href(item.assets["opendap"]) for item in collection] fails cause collection does not end properly?
  • collection = STAC.FeatureCollection(url,query) fails, not sure why

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 50.00% and project coverage change: -1.58 ⚠️

Comparison is base (9f0160f) 96.62% compared to head (6236557) 95.05%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
- Coverage   96.62%   95.05%   -1.58%     
==========================================
  Files           7        7              
  Lines         178      182       +4     
==========================================
+ Hits          172      173       +1     
- Misses          6        9       +3     
Impacted Files Coverage Δ
src/search.jl 88.57% <50.00%> (-8.21%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@gaelforget gaelforget marked this pull request as draft May 3, 2023 01:42
@Alexander-Barth
Copy link
Member

It seems that if we make a get request then the collection_concept_id parameter get propagated automatically:

using STAC, URIs, Dates, HTTP, JSON3


timerange = (DateTime(2005,1,1),DateTime(2005,1,2))
collection_concept_id= "C1299783579-LPDAAC_ECS"

url = "https://cmr.earthdata.nasa.gov/search/granules.stac"

query = query = Dict(
    "collection_concept_id" => collection_concept_id,
    "temporal" => join(string.(timerange),','),
    "pageSize" => 100,
)

function FeatureCollection2(url,query; method=:post)
    if method == :get
        url = string(URI(URI(url), query = query))
    end

    ch = Channel{STAC.Item}() do c
        while true
            if method == :post
                @debug "post $url" query
                r = HTTP.post(url,[],JSON3.write(query))
            else
                @debug "get $url"
                r = HTTP.get(url)
            end
            data = JSON3.read(String(r.body))
            for d in data[:features]
                put!(c,STAC.Item("",d,STAC._assets(d)))
            end

            # check if there is a next page
            next = filter(d -> get(d,"rel",nothing) == "next",data[:links])
            # no more next page
            if length(next) == 0
                break
            else
                url = next[1][:href]
            end
        end
    end
end

collection = collect(FeatureCollection2(url,query, method=:get))

@show length(collection)
# output 402

I could not find any collection that supports opendap:

curl "https://cmr.earthdata.nasa.gov/search/collections.json?page_size=100" | python -m json.tool

What ever I query C1996881146-POCLOUD gives always an empty collection. Currently podaac.jpl.nasa.gov is down. Maybe this is related.

@Alexander-Barth
Copy link
Member

Alexander-Barth commented May 15, 2024

This problem should be fixed now:

e163edb

Thank for letting me know.

@gaelforget
Copy link
Member Author

This problem should be fixed now:

e163edb

Thank for letting me know.

Works for me now. Thanks for this!

@gaelforget gaelforget closed this May 16, 2024
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.

3 participants