-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add random user ID for Nominatim and allow arbitrary geocoder #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few suggestions!
contextily/place.py
Outdated
# Set user ID for Nominatim | ||
rng = np.random.default_rng() | ||
val = rng.integers(1000000) | ||
gp.geocoders.options.default_user_agent = f"contextily_user_{val}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we only set this in the actual geocoder object we create below?
Because now importing contextily will have a side effect on the geopy module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darribas are you OK with only passing this "contextily_user_val" to the gp.geocoders.Nominatim()
default keyword value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darribas are you ok with this? Then I can push a change, merge this, and do a small bug fix release
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds great and a much cleaner way to go about. I'm +1 on this
It also seems that I made a small mistake in my PR (hidden by those failures), from the travis log:
If not warping, we need to get the bounds from |
rng = np.random.default_rng() | ||
val = rng.integers(1000000) | ||
gp.geocoders.options.default_user_agent = f"contextily_user_{val}" | ||
_val = np.random.randint(1000000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good and more backwards compatible. I tried to go with the numpy recommendation but if it's not a widespread approach yet and fails on earlier versions, let's go with randint
OK, updated to only use the default contextily user agent for the actual Nominatim geocoder that is created as the default. |
…iles * commit '3c26d5a16a094e8d5ae05f8e5a41f05278816daf': DOC: update for latest pydata-sphinx-theme (fix sidebar + use CSS variables) (geopandas#168) RLS: v1.0.1 Fix resetting of extent with local files (geopandas#155) (geopandas#156) Add random user ID for Nominatim and allow arbitrary geocoder (geopandas#164) Close and reopen memfile dataset before WarpedVRT (geopandas#165) Fix use of rasterio MemoryFile (geopandas#163) DOC: Use Cape Town consistently in description and variable names (geopandas#154) Add matplotlib Framework classifier (geopandas#152) Require Python 3.6 as minimum version (geopandas#150) Add earthengine to docker for binder Example interfacing GEE with contextily (geopandas#147) DOC: add notebook about working with local files (geopandas#139) # Conflicts: # tests/test_ctx.py
This addresses #44