-
Notifications
You must be signed in to change notification settings - Fork 30
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
Download with geometry parameter #81
Comments
thanks, on leave until may 3, will have a look then |
Wasn't quite sure, had to look this one up, see https://github.com/sckott/pygbif/blob/master/test/test-occurrences-download_request.py#L83 Seems a little bit different from other queries, have to use e.g., req = GbifDownload("name", "email")
req.add_geometry(
"POLYGON((-14.06 42.55, 9.84 38.27, -7.03 26.43, -14.06 42.55))"
)
req.post_download() |
Scott,
Thank you for looking into this. This is my first time submitting an issue
that required edits on the part of a contributor. How should I proceed?
Download and test the development version and confirm that the error was
fixed for my application?
Nathan
…On Thu, May 6, 2021 at 7:52 PM Scott Chamberlain ***@***.***> wrote:
Wasn't quite sure, had to look this one up, see
https://github.com/sckott/pygbif/blob/master/test/test-occurrences-download_request.py#L83
Seems a little bit different from other queries, have to use GbifDownload
to construct a class first, then add_geometry
e.g.,
req = GbifDownload("name", "email")req.add_geometry(
"POLYGON((-14.06 42.55, 9.84 38.27, -7.03 26.43, -14.06 42.55))"
)req.post_download()
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#81 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEMYMOGPKHJED7VTBEEYTSLTMMTSHANCNFSM43NL7V7Q>
.
--
*Nathan Tarr*
Research Scholar
NC Cooperative Fish and Wildlife Research Unit | Department of Applied
Ecology
NC State University
website <https://nmtarr.wordpress.ncsu.edu/>
All electronic mail messages in connection with State business which are
sent to or received by this account are subject to the NC Public Records
Law and may be disclosed to third parties.
|
@nmtarr Yes, download dev version from github |
@sckott I downloaded the dev version, but I'm still getting the error as described above. Can someone please confirm that my geometry parameter should indeed be formatted like this: "geometry within 'POLYGON ((-82.7 36.9, -85.0 35.6, -81.0 33.5, -79.4 36.3, -79.4 36.3, -82.7 36.9))'" I'm not confident that I've got it right. Thanks for the help. |
The string you supply to |
@sckott Thanks. That makes sense for use of add_geometry. I would really like to be able to include a geometry parameter with occurrences.download. The documentation for that function states that geometry can be included. Is that not actually the case? |
- bump package version - add a test for adding geometry via a string rather than via add_geometry - (unrelated: also remove response header content-type check in gbif_GET_write because ctype has changed)
Got it now, thanks for clarifying. Okay, just pushed a change on branch geometry-predicate. The download predicate logic was splitting strings on spaces, which doesn't work for geometry predicate since you can't remove spaces from a WKT string. Should work now after reinstalling from github. Let me know if works. |
It is working for me now. Thanks for addressing the issue! |
Awesome, glad it works now. i'll PR the change to the main branch and seek a bit of feedback first from other contribs |
- bump package version - add a test for adding geometry via a string rather than via add_geometry - (unrelated: also remove response header content-type check in gbif_GET_write because ctype has changed)
Hello,
I can't seem to figure out how to run occurrences.download() with a geometry parameter successfully. I've tried enough tweaks to get to the point of wondering if there's a bug. Anyone got any advice?
I'm using Python 3.7.10 and pygbif 0.5.0. Here is my code; it works without the geometry parameter:
------------------------------------------------
from pygbif import occurrences
username = 'xxxxxx'
password = 'xxxxxx'
email = 'xxxxxx'
download_filters = ["taxonKey = 2496287",
"geometry within 'POLYGON ((-82.7 36.9, -85.0 35.6, -81.0 33.5, -79.4 36.3, -79.4 36.3, -82.7 36.9))'"]
download = occurrences.download(download_filters,
pred_type='and',
user = username,
pwd = password,
email = email)
#-------------------------------------------------
And here is the error message:
Exception: error: JSON parse error: Cannot construct instance of
org.gbif.api.model.occurrence.predicate.WithinPredicate
, problem: may not be null; nested exception is com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance oforg.gbif.api.model.occurrence.predicate.WithinPredicate
, problem: may not be nullat [Source: UNKNOWN; line: -1, column: -1] (through reference chain: org.gbif.api.model.occurrence.predicate.ConjunctionPredicate["predicates"]->java.util.ArrayList[1]), with error status code 400check your number of active downloads.
Regards,
Nathan
The text was updated successfully, but these errors were encountered: