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

usgs uses minimum bounding rectangle now for spatial filter #47

Open
rbavery opened this issue Sep 25, 2019 · 8 comments
Open

usgs uses minimum bounding rectangle now for spatial filter #47

rbavery opened this issue Sep 25, 2019 · 8 comments

Comments

@rbavery
Copy link

rbavery commented Sep 25, 2019

https://earthexplorer.usgs.gov/inventory/documentation/test?version=1.3.0 used ll and ur coordinates but the later api versions use the MBR. I think this might be what is causing my Remote Disconnected errors.

This payload would need to be updated in the search function, I'll see if I can fix this and submit a PR if PRs are being accepted.

@kapadia
Copy link
Owner

kapadia commented Sep 25, 2019

Yep, PRs welcome. There was some effort to update some calls to the v1.4 API, such as during login, but not everything was updated.

Feel free to drop your usage here, and I'll can try to confirm the issue if you're not entirely sure.

@rbavery
Copy link
Author

rbavery commented Sep 25, 2019

Awesome thanks! Here is my call

from usgs import api results = api.search("ARD_TILE", "EE", start_date="2002-06-01" , ll={"longitude":-103.962375,"latitude":40.132703}, ur={"longitude": -95.192605,"latitude": 42.950893}, api_key=token)

@kapadia
Copy link
Owner

kapadia commented Sep 25, 2019

Try this in your shell. Make sure you're logged in as well

usgs search --node EE ARD_TILE --start-date 2002-06-01 --end-date 2002-06-07 --lower-left -103.962375 40.132703 --upper-right -95.192605 42.950893 --geojson

Your query doesn't set an end date, which, in my experience tends to cause the USGS servers to hang. If you're trying to search from 2002 to current, you'll want to chunk the queries along the date range. Try one month intervals to start. If that's successful in a reasonable amount of time, expand the time range. If that falls over, try reducing to one or two week intervals.

@rbavery
Copy link
Author

rbavery commented Sep 25, 2019

I get the following error running that line, not sure what's going on.

# rave at rave-thinkpad in ~ [14:37:33]
→ usgs search --node EE ARD_TILE --start-date 2002-06-01 --end-date 2002-06-07 --lower-left -103.962375 40.132703 --upper-right -95.192605 42.950893 --geojson
Traceback (most recent call last):
  File "/home/rave/miniconda3/bin/usgs", line 10, in <module>
    sys.exit(usgs())
  File "/home/rave/miniconda3/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/rave/miniconda3/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/rave/miniconda3/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/rave/miniconda3/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/rave/miniconda3/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/rave/miniconda3/lib/python3.7/site-packages/usgs/scripts/cli.py", line 211, in search
    print(json.dumps(result))
  File "/home/rave/miniconda3/lib/python3.7/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/home/rave/miniconda3/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/home/rave/miniconda3/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/home/rave/miniconda3/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type map is not JSON serializable

It looks like the result is received but can't be printed with json.dumps so maybe it is a python version issue, I'll try this in a different env

@rbavery
Copy link
Author

rbavery commented Sep 25, 2019

The error also occurs on python 3.6.7

@rbavery
Copy link
Author

rbavery commented Sep 26, 2019

I'm not sure what the issue is with the cli, but I've made a PR that adds geojson filtering for the python api. My PR doesn't seem to fix or change the above error for the cli.

@kapadia
Copy link
Owner

kapadia commented Sep 26, 2019

Likely a version issue. I'll take a look tomorrow.

@arbab-vassar-labs
Copy link

@kapadia I've made an effort to implement GeoJSON filtering, but unfortunately, it doesn't appear to be functioning as intended. Would you be so kind as to inform me if this issue has already been addressed? Your assistance would be greatly appreciated.

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

No branches or pull requests

3 participants