Natural Language Processing
In this part, we'll geocode our proper nouns using Google. READ ALL THE PAGE BEFORE DOING ANYTHING: IT INCLUDES WARNINGS.
To geocode our proper nouns, we'll use the Google geocoding API (details). There are libraries for using this (geopandas, for example), but it is just as easy to do by hand. Here's some code to do one address by Pablo Navarro: GitHub. Can you adapt it to do multiple proper nouns?
A few things to note.
Firstly, you only need one parameter: address
, and this can be a single word. The other params can go.
Secondly, the Google Geocoding API will return an error if the location isn't recognised or some other fault. You can filter results with:
if res['results']:
Thirdly, the API has a 50 requests per-second limit. You might like to add a few fractions of a second between requests.
Finally, although this API will return results for a bit, it will eventually block your IP address if you don't have an API key. We don't want that.
You can get an API key on the Google Geocoding API site and
find out how to use it here. Note that
some options will charge you so DO NOT ENABLE BILLING and DO NOT UPLOAD CODE CONTAINING YOUR API KEY TO GITHUB. The standard setup gets a fixed number of
free requests. Even so, you want to limit the requests you make during development.
Experiment with a proper noun you know exists. I used for noun in propernouns[13:14]:
as my loop, which just gave me Starnbergersee
.
Have a go, and see what you can develop.