Get Geographical Coordinates from Google Maps API for any Address. Real Python example.

preview_player
Показать описание
Python is very flexible tool to get any available data from Google Maps API server to your working data structure (as Pandas Dataframe).

Google Maps API provide a wide range of data about requested records by returning a dictionary of data back to your project.
In this example I use just random addresses of real estate properties from Zoopla for get geographical coordinates (as latitudes and longitudes) for them. This is how you can convert any address or name of location to geographical coordinates by API service.

This video contained of 3 parts: the first one is how to get Google Maps API key and second one - how to write Python code to get latitudes and longitudes for the properties. And the 3rd part demonstrates how result of geocoding is looking.

The content of the video:

Part 1. Get Google Maps API key for using. 0:03
# 1. 0:07 Go to Google Console page
# 2. 0:14 Create a new API project if do not have it yet
# 3. 0:24 Create a new API key for API project
# 4. 0:35 Give a name for API key for identification
# 5. 0:42 Check restrictions for API. There should be None.
# 6. 0:56 Give access to Google Maps API for geocoding (press Enable there!)

Part 2: Write python code for create data structure by including latitudes and longitudes from Google server.
In this part we will use Pandas module for manipulating records of data.
# Task of project: 1:18
# 1. 1:25 Import googlemaps module to the project
# 2. 1:33 Set Google Maps API key from Google Console API page
# 3. 1:50 Copy key from Google Console API page and paste it to Python code
# 4. 2:04 Create Geocode object. This is full dataset for an object from Google server
# 5. 2:09 Create empty columns in Pandas Dataframe that will store dat for Latitudes and Longitudes.
# 6. 2:23 Go through all objects and get Latitudes and Longitudes for them.
# 3:10 Get the value of latitude from result of request to Google API.
# 3:52 Write values to Pandas dataset (to LAT and LON columns)
# 4:27 Tell the model what to do if the request return False.
# 4:39 Testing the project.

# 4:59 Part 3. What is result of geocoding?
You can get much more data Google Maps API results.

Рекомендации по теме
Комментарии
Автор

Thank you very much !!! I tried many times to find information about geocoding google api in Korean & English. This is the best information ever. Now I can restart my personal project again :)

_HF-ohev
Автор

How can we detect our current geolocation without address?

SahajOberoi
Автор

Great video! Helped me do exactly what I needed. Thank you so much!

vsharat
Автор

Thanks for the video. I have a dataset with Lat/long. How can I get the City, Zip, State for those lat/long in the dataset by using pandas/python? I gave the google map api.

shamiul
Автор

Congrats for this video. It helped me a lot and in a clearly way!

oswaldobarajas
Автор

Hello! thank you very much for this great tutorial! It has helped me a lot. Could you give an example how to print the country or some other "address_components" thanks!

yerkobaezalagos
Автор

Thanks a lot for this so helpful video

issabarack
Автор

thanks a lot for this video it was very helpful, i would like to ask you some questions did you use the directions api and geocoding api as for the jupyter notebook can we work from anaconda or we have to work on the virtual machine instance provided by GCP thanks again

mohamedragoubi
Автор

Great explanation, but how can we find the lat and long using the open location code aka (+ code).

vipulkumar
Автор

Hey ! I ran the particular piece of cod but the problem is that I am not able to get the longitudinal values.The latitudinal values show up fr 95% of the datasets but the longitudinal values do not show up.Do you know the reason why?
Regards,
Mrinal Subash

mrinalsubash
Автор

I have been trying to get coordinates for a district boundary to create a choropleth map using folium. But that district boundary coordinates are missing in Nominatim. Now i am stuck with this. Is there any way to solve this problem?

mesbahuddin
Автор

Hey ! Great video .Although I have a query.I am not able to access the googlemaps function without putting my billing credentials.Is it necesaary for me to do that in order to map specific static locations on the map?Do reply in the earliest.
Regards,
Mrinal

mrinalsubash
Автор

TypeError: _get_value() got multiple values for argument 'takeable'

I am getting this error. What to do?

aishwaryamuthukumar
Автор

hey. i want to ask, whether it is possible to get the address for all possible locations.
for example: I want to get location of all mcdonalds in Los Angeles, is it possible to make query like that? if yes, could you explain how to do that?

andhikaputrapratama
Автор

Hi! thank you for your helpful video but i have 1 problem. i have an error on importing googlemaps. how can i install googlemaps using a mac? thanks

glennrapa
Автор

Hello, Thank you for the video.

I have a question about a similar task.
I am new to python and I need your support in a small task.

I drew a line manually on google earth around 10 m using the feature “Draw Line” by connecting 10 points so basically by clicking 10 times to get the complete line because I need the distance between each point to be 1 m.

Now the question is, how can I do that in a python script automatically? I need to do it for longer lines and there must be a way to do it in python.



I would be very thankful for any assistance.
Thank you in advance

raafsports
Автор

where should we get the csv file from?

aqibhuda
Автор

Hi! Thank you and how to do the reverse geocoding, especially with a long list of lat/lon columns

lexiejin
Автор

Hi thanks for the video! Would like to ask if this would also work in Python 2?

qiwenong
Автор

very great example. unfortunately right now, google map API is not free any more.

binghanwu