Basically, I am trying to get the latitude and longitude to visualize on a map using address (zip code). In the Nominatim library, I keep getting errors on certification verification. What do I put under the user_agent parameter?
You can do this with geopandas (https://geopandas.org/en/stable/docs/user_guide/geocoding.html)
Another option is to use pgeocode (https://pypi.org/project/pgeocode/). But for pgeocode library work, it is crucial to download a txt file that contains the postal codes from the specific country of interest. You can find this files in http://download.geonames.org/export/zip/ and download the file corresponding to the country that you are looking for (i.e. US.zip for US, UK.zip for United Kingdom, BR.zip for Brazil).
geopy is a Python client for a number of well-known geocoding web services. Using third-party geocoders and other data sources, geopy makes it simple for Python developers to get the coordinates of addresses, cities, nations, and landmarks all around the world.
The first step is to install Geopy.
1. Install geopy with pip. Creating a Connection
2. Import Nominatim from geopy.geocoders.
3. import geopy.extra.rate limiter RateLimiter.
4. place = geocode.reverse((lat, long))
5. raw location
6. zipcode = raw location
['address']['postcode']
7. # after starting the geocoder
After we've created the address column, we can begin geocoding, as seen in the code excerpt below.
#1 — We begin by delaying our geocoding by one second between each address.
#2 — Using the geocode we created, add a df['location'] column.
#3 — Finally, we can build a single tuple column with latitude, longitude, and altitude.