2

I am trying to download all the building addresses on a specific street.

Is it possible to download all addresses using Google Maps API as building address are available online in maps but API is not showing all addresses.?

enter image description here

The attempt that I have made

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)

# import the library
import googlemaps
import json
import pprint
import xlsxwriter
import time
import pandas

# Define the API Key.
API_KEY = 'AIzaSy---------------------------------'

# Define the Client
gmaps = googlemaps.Client(key = API_KEY)


#places_result  = gmaps.places_nearby(location='-33.8670522,151.1957362', radius = 40000, open_now =False , type = 'Building')
places_result  = gmaps.places_nearby(location='-38.339655,143.58063649963287', radius = 50000, open_now =False , type = 'cafe')

time.sleep(3)

place_result  = gmaps.places_nearby(page_token = places_result['next_page_token'])

stored_results = []

# loop through each of the places in the results, and get the place details.
for place in places_result['results']:

    # define the place id, needed to get place details. Formatted as a string.
    my_place_id = place['place_id']

    # define the fields you would liked return. Formatted as a list.
    my_fields = ['name','place_id','geometry']

    # make a request for the details.
    places_details  = gmaps.place(place_id= my_place_id , fields= my_fields)

    # print the results of the details, returned as a dictionary.
    pprint.pprint(places_details['result'])

    # store the results in a list object.

    stored_results.append(places_details['result'])

# -------------- DUMPING VALUES IN EXCEL -----------------------

# define the headers, that is just the key of each result dictionary.
row_headers = stored_results[0].keys()

#%%
#%%
# create a new workbook and a new worksheet.
workbook = xlsxwriter.Workbook(r'C:\Users\Ali\OneDrive - UNSW\Zepben_coding\Line_2020\'Google_Coordinates.xlsx')
worksheet = workbook.add_worksheet()

Is there any other way to collect all the addresses of buildings from a specific location?

After address I want to geocode into Lat/Long information.

1
  • 3
    Other than the tag and title refernce, this question has no ArcGIS relevance, proving that the One question per Question policy really is for the best.
    – Vince
    Jun 5, 2020 at 3:57

2 Answers 2

1

Foreword: This answer does not contain corrections to the author's code

Before digging into the scripting I highly recommend to investigate approaches with no coding.

Here I tried to describe a couple of options that may be useful.

Option 1. Looking for open public data

Try exploring some address catalogues provided by government, city administrations and other authorities in your country. Many addresses you can now find online, they are available for free of charge and they surely respond to a high quality standard. With this schema you won't need any geocoding.

Option 2. Application of OpenSteetMap

Try investigating possibilities to export OSM data.

I think it partially overlaps with one of my previous questions, namely Full address list for city Radebeul (Germany).

Option 3. Using ArcGIS/Google Maps Geocoder API and Reverse Geocoder API

Here is a workflow that I may be following when required a data quality from one of the commonly known Geo-Companies.

  1. Extracting by the street name its geometry

    e.g. LINESTRING (0 1, 1 3, 5 5)
    
  2. Creating a right-minded buffer around that street geometry

  3. Generating N-points inside of that buffer

  4. Geocoding each point with ArcGIS/Google Maps Reverse Geocoder

  5. Filtering the output, thus only unique addresses' numbers remain and that possess the required street name

  6. Geocoding addresses with ArcGIS/Google Maps Geocoder


References:

0

Approach one Do you have the ability to mark manually each building on the map you are interested:

  1. like create your own map markers by marking each one on the map street you are interested.
  2. On the back collect their coordinate as lat and long in list.
  3. reverse geocode the list and obtain the full address using reverse google maps geocoder api.
  4. display results or use them anywhere you want.

Approach Two:

This one will involve using AI on the back.

  1. Create ability to select polygon with street with buildings from a map.
  2. Train the selection as to recognize what is building on the map using manually selected map markers(see approach one).
  3. Over time, AI will auto recognize using the map tile what is a building, will get the coordinates, and will use reverse engineering to obtain the the addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.