usgs icon indicating copy to clipboard operation
usgs copied to clipboard

usgs uses minimum bounding rectangle now for spatial filter

Open rbavery opened this issue 6 years ago • 8 comments

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.

rbavery avatar Sep 25 '19 20:09 rbavery

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.

kapadia avatar Sep 25 '19 20:09 kapadia

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)

rbavery avatar Sep 25 '19 21:09 rbavery

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.

kapadia avatar Sep 25 '19 21:09 kapadia

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 avatar Sep 25 '19 21:09 rbavery

The error also occurs on python 3.6.7

rbavery avatar Sep 25 '19 21:09 rbavery

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.

rbavery avatar Sep 26 '19 00:09 rbavery

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

kapadia avatar Sep 26 '19 21:09 kapadia

@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.

arbab-vassar-labs avatar Aug 22 '23 11:08 arbab-vassar-labs