Where to Open a Chinese Restaurant in Amsterdam using TomTom Maps APIs
Xinrong Ding·Jan 10, 2020

Where to Open a Chinese Restaurant in Amsterdam using TomTom Maps APIs

Xinrong Ding
Jan 10, 2020 · 16 min read

If you're looking to open a restaurant you'll need to take into consideration location and where competitors are. By using surrounding data and demographic data you can create map that helps you visualize the best location to open up your restaurant.

Table of Contents:1. Introduction2. Data Requirements3. View Candidate Neighborhoods on a Map4. Explore the Surroundings5. In-Depth Analysis of One Neighborhood6. Conclusion and Future Work

[1. Introduction]

This is the virtual challenge I chose in order to complete an online Data Science course. I had so much fun tackling the challenge using TomTom Maps APIs that I would like to share the project with others!

1.1 The Challenge

Linda has a dream to open a Chinese restaurant and share the joy of great food with others. Now that everything is ready, she chooses Amsterdam to be the place where her dream takes off. Amsterdam is a diverse, exciting place, but its high tourism and population make finding the optimal location challenging.

1.2 The Approach

Linda is planning to open her Chinese restaurant in Amsterdam. I need to collect data from at least two sources to narrow down her selection:

  • Demographic data (for instance: population density per area in Amsterdam)

  • Data of the surroundings (for instance: density of similar restaurants nearby)

Since you are here to read about fantastic things you can do with TomTom Maps APIs, I will be much more focused on the second part: Data of the surroundings. If you are interested in the complete story, please read the full story here.

1.3 Business Questions

To find the ideal location for the restaurant, I must first seek answers to these questions.

Question 1: How popular will Chinese food be in the neighborhood?

For Linda, it's important to serve traditional Chinese food in same the style in which she learned to first create her dishes. Even though Chinese food is widely loved, it makes sense to double check how existing Chinese restaurants are perceived. I will seek to answer this question using TomTom Maps APIs.

Question 2: Who are the target customers and where do they live?

It is going to be a small restaurant (5 to 7 tables) due to the limited investment. The primary income would be takeout and orders made online. From past experience, Linda knows that people who live alone are more likely to buy takeout or use online food ordering apps such as Uber Eats. They are the ideal target customers for her new restaurant. So, I will look for an area with a relatively high density of one-person household. I need demographic information to answer this question.

[2. Data requirements]

My focus point for Linda’s new restaurant is location, location, location… Thus, I need to collect data that can help me answer the questions, which falls into two main categories:

  • Data of the surroundings (density of similar restaurants nearby)

  • Demographic data (per area in Amsterdam)

2.1 Data of Surroundings

TomTom Search API: To find all points of interest (POI) per category around a certain location, I will utilize TomTom Search:

2.2 Demographic data

Demographic features that are crucial to learn for this project:

  • Total Households: Number of households in a neighborhood.

    • High number of total households guarantees a solid base of potential customers.

  • Population density: A more densely populated area means more customers for a restaurant. The unit of population density is number of people per square kilometer.

    • On top of total households, this feature tells us how many households there are within a given area. Since people living nearby are more likely target customers, the more densely populated neighborhood is a more ideal choice.

  • One-person Households: Number of households with only one-person residing.

    • One-person households are perfect target customers, as these individuals are more likely to order takeout and avoid cooking alone.

Demographic analysis is definitely essential to start narrowing down neighborhoods in Amsterdam. However, it is not the focus of this article. If you are interested in learning more about this process (including demographic data analysis), please read the full story.

2.3 Conclude demographic analysis

From studying and analyzing demographic data, I chose 10 out of 65 neighborhoods in Amsterdam. Now, I want to display all of these neighborhoods on a map, to give Linda some visuals so she can make her decision more easily!

[3. View candidate neighborhoods on a map]

I use these tools to visualize the information I gathered above:

  • TomTom Map: map data

  • Folium: map rendering library

Load the information of the 10 remaining neighborhoods into a dataframe:

1In [2]:
2# library to handle data in a vectorized manner
3import numpy as np 
4# library to load dataframe
5import pandas as pd
7# Matplotlib and associated plotting modules
8import matplotlib.colors as colors
9import matplotlib.pyplot as plt

The CSV file that is loaded below is cleaned up based on analyzing demographic data. In the full story, I explain how to process the data from a larger dataset.

1In [3]:
2#Load the csv file.
3df = pd.read_csv('https://dl.dropboxusercontent.com/s/3781fqm6w2i3gir/Amsterdam_top10.csv')
1Out [3]:

In [4]:Install and import folium

1#pip install folium==0.9.1 #comment it out if folium is already installed
1In [5]:
2import folium # map rendering library

3.1 Use TomTom Search API

Sign up for a developer portal account, and then click “Get your key” on this page to get an API key you can use!

Load the TomTom API

TomTom API offers multiple APIs, including the Search API. There is no need to load each API separately.

1In [6]:
2import requests
3tomtom_api_keys = ["YOUR TOMTOM API KEY"] # 2500 free calls/day
4api_key = tomtom_api_keys[0]

Establishing the map

First, I want to define a function using Geocoding feature in Search API to get lat/lon of the center of a city. In this case, I retrieve the center of Amsterdam so that the map is properly aligned in the view.

1In [7]:
2# Search for city:
3def SearchCity(api_key,City,Country):
5    url = 'https://api.tomtom.com/search/2/search/'
6    url += City + ', ' + Country
7    url += '.json?limit=1&idxSet=Geo&key=' + api_key
9    result = requests.get(url).json()
11    GeoID = result['results'][0]['dataSources']['geometry']['id']
12    position = result['results'][0]['position']
14    return GeoID,position
1In [8]:
2# Use the SearchCity function to get the lat/lon of Amsterdam
3Amsterdam_position = SearchCity(api_key, "Amsterdam", "Netherlands")
4lat_amsterdam = Amsterdam_position[1]['lat']
5lon_amsterdam = Amsterdam_position[1]['lon']
6print("Center of Amsterdam lat/lon: (", lat_amsterdam, lon_amsterdam, ")")

The output should be Center of Amsterdam lat/lon: ( 52.37317 4.89066 ).

Now, let’s instantiate the visual component, the TomTom map itself, so I can begin displaying neighborhoods.

1In [9]:
2#Define a function to initialize any map using TomTom map.
3def init_map(api_key=api_key, latitude=0, longitude=0, zoom=14, layer = "basic", style = "main"):
4    """
5    The initialise_map function initializes a clean TomTom map
6    """
8    maps_url = "http://{s}.api.tomtom.com/map/1/tile/"+layer+"/"+style+"/{z}/{x}/{y}.png?tileSize=512&key="
9    TomTom_map = folium.Map(
10        location = [latitude, longitude],  # on what coordinates [lat, lon] initialise the map
11        zoom_start = zoom,  # with what zoom level to initialize the map, from 0 to 22
12        tiles = str(maps_url + api_key),
13        attr = 'TomTom')
15    return TomTom_map

3.2 Visualize one feature on the map

Let's start from visualizing the number of one-person households on the map to get an impression of the 10 candidate neighborhoods.

1In [10]:
2#Visualize one feature (number of one-person households) to get an impression of the 10 candidate neighborhoods.
3TomTom_map = init_map(latitude=lat_amsterdam, longitude=lon_amsterdam, zoom=13, layer = "hybrid")
5# add markers to map
6for lat, lon, neighborhood, oph in zip(df['Lat'], df['Lon'], df['Neighborhood'], df['One-person Households']):
7    label = '{}'.format(neighborhood)
8    label = folium.Popup(label, parse_html=True)
9    folium.Circle(
10        [lat, lon],
11        radius=oph/25,
12        popup=label, 
13        color='#FF7F0F', # Orange
14        fill=True,
15        fill_color='#FF7F0F',
16        fill_opacity=0.3).add_to(TomTom_map)
1Out [10]:
Locate different points of interest on a map using TomTom Maps

3.3. Visualize more features on the map

The above map gives us an impression of how many one-person households actually exist in each neighborhood.

Now, let's add two more features to the map, so there will be three features in total:

  1. Orange circles represent the number of one-person households.

  2. Blue circles represent the number of households in total.

  3. Green circles represent the population density.

Important notes about these circles:

  • The center of the orange, green, and blue circles is the center of the neighborhood.

  • Click the center of the circles to see the name of the neighborhood.

  • The radius of each circle represents the number of each feature.

In order to show a more zoomed in map view, I re-adjust the center of the map.

Re-adjust the center of the 10 candidate neighborhoods. Based on the previous map visualization, I can see a better center for further analysis is the address: Prinsengracht 745A Amsterdam.

1In [11]:
2url = "https://api.tomtom.com/search/2/geocode/Prinsengracht 745A Amsterdam.json?countrySet=NL&key=" + api_key
3result = requests.get(url).json()
1In [12]:
2lat_center = result['results'][0]['position']['lat']
3lon_center = result['results'][0]['position']['lon']
4print(lat_center, lon_center)
152.36425 4.88628
Drawing the Map with One-person Households, Total Households, and Population Density.
1In [23]:
2TomTom_map = init_map(latitude=lat_center, longitude=lon_center, zoom=14, layer = "hybrid")
4# add markers that represent one-person households to the map
5for lat, lon, neighborhood, oph in zip(df['Lat'], df['Lon'], df['Neighborhood'], df['One-person Households']):
6    label = '{}'.format(neighborhood)
7    label = folium.Popup(label, parse_html=True)
8    folium.Circle(
9        [lat, lon],
10        radius=oph/25,
11        popup=label,
12        color='#FF7F0F', # Orange
13        fill=True,
14        fill_color='#FF7F0F', 
15        fill_opacity=0.3
16    ).add_to(TomTom_map)
18# add markers that represent total households to the map
19for lat, lon, neighborhood, households in zip(df['Lat'], df['Lon'], df['Neighborhood'], df['Total Households']):
20    label = '{}'.format(neighborhood)
21    label = folium.Popup(label, parse_html=True)
22    folium.Circle(
23        [lat, lon],
24        radius=households/25,
25        popup=label,
26        color='#1E77B4', # Blue
27        fill=False
28    ).add_to(TomTom_map)
30# add markers that represent population density to the map
31for lat, lon, neighborhood, density in zip(df['Lat'], df['Lon'], df['Neighborhood'], df['Population Density']):
32    label = '{}'.format(neighborhood)
33    label = folium.Popup(label, parse_html=True)
34    folium.Circle(
35        [lat, lon],
36        radius=density/100,
37        popup=label,
38        color='#2A9E2A', # Green
39        fill=False
40    ).add_to(TomTom_map)
1Out [23]:
Visualize data points on a map using TomTom's Map SDK

As you can see, when choosing an ideal location to open the Chinese restaurant:

  • The bigger the green circles the better.

  • The less difference between the size of the blue circles and the orange circles the better.

3.4. Conclusion and Next Steps

Based the above analysis, I have chosen 10 out of 65 neighborhoods in Amsterdam city proper as the candidate neighborhoods for us to investigate further.

The next step, covered in the next chapter, will be to further analyze the 10 neighborhoods by looking into the density of Chinese restaurants in each. This will help me narrow down Linda’s choices for the best exact location for her new restaurant!

[4. Explore the surroundings]

Now, I know where the remaining 10 neighborhoods are located and their geo-relationship relative to each other. It's time to explore the surroundings. In the scope of the project, I will focus on only question in this space.

4.1. How many Chinese restaurants are already available in each neighborhood?

TomTom Search allows single-line fuzzy search for addresses and POIs, which I will use since I take into account more neighborhood attributes for Linda’s restaurant. Use the Search API explorer to get the url. I choose to store all search results in a JSON file. Some key variables:

  • Search radius: radius

  • Maximum number of search results: limit

1In [20]:
2search_radius = 3000
3search_limit = 2000
1In [35]:
2url = ('https://api.tomtom.com/search/2/categorySearch/Chinese restaurant.json?countrySet=NL'
3       +'&lat=52.364250&lon=4.886280&limit=2000&radius=3000&key=' + api_key)
4result = requests.get(url).json()

One of the search results in the JSON file.

1In [ ]:
2{'type': 'POI',
3   'id': 'NL/POI/p0/109857',
4   'score': 5.14904,
5   'dist': 150.32529954911772,
6   'info': 'search:ta:528009005857203-NL',
7   'poi': {'name': 'Taste Of Culture',
8    'phone': '+(31)-(20)-4271136',
9    'categorySet': [{'id': 7315012}],
10    'url': 'www.tasteofculture.net',
11    'categories': ['chinese', 'restaurant'],
12    'classifications': [{'code': 'RESTAURANT',
13      'names': [{'nameLocale': 'en-US', 'name': 'chinese'},
14       {'nameLocale': 'en-US', 'name': 'restaurant'}]}]},
15   'address': {'streetNumber': '139HS',
16    'streetName': 'Korte Leidsedwarsstraat',
17    'municipalitySubdivision': 'Amsterdam',
18    'municipality': 'Amsterdam',
19    'countrySubdivision': 'North Holland',
20    'postalCode': '1017',
21    'extendedPostalCode': '1017PZ',
22    'countryCode': 'NL',
23    'country': 'Netherlands',
24    'countryCodeISO3': 'NLD',
25    'freeformAddress': 'Korte Leidsedwarsstraat 139HS, 1017PZ, Amsterdam',
26    'localName': 'Amsterdam'},
27   'position': {'lat': 52.36311, 'lon': 4.88509},
28   'viewport': {'topLeftPoint': {'lat': 52.36401, 'lon': 4.88362},
29    'btmRightPoint': {'lat': 52.36221, 'lon': 4.88656}},
30   'entryPoints': [{'type': 'main',
31     'position': {'lat': 52.36305, 'lon': 4.885}}]},

I can learn from the above JSON file that the following information is essential to show Chinese Restaurants on the map:

  • Get lat lon from:'position': {'lat': 52.36311, 'lon': 4.88509},

  • Get name from: 'poi': {'name': 'Taste Of Culture'

Now, let’s show these restaurants.

4.2. Showing the Chinese restaurants on the map

Use the position and name information extracted from the JSON file to show POIs on the map.

1In [22]:
2# add a grey circle to represent the search radius
4    [lat_center, lon_center],
5    radius=search_radius,
6    color='#004B7F', # Navy
7    opacity=0.3,
8    fill = False
11# Add POIs one by one to the map
12for poi in result['results']:
13    folium.Marker(location=tuple(poi['position'].values()),
14                  popup=str(poi['poi']['name']), 
15                  icon=folium.Icon(color='blue', icon='glyphicon-star')
16                  #icon=icon
17             ).add_to(TomTom_map)
1Out [22]:
Add map markers to your map using TomTom Maps SDKLegends of the above map:
  1. Blue markers: Chinese restaurants.

  2. Orange circles: the number of one-person households.

  3. Blue circles: the number of households in total.

  4. Green circles: the population density.

  5. Grey circle: the search radius.

4.3. Cluster the POIs

What I would really like to do is have a more obvious visual as to the number of Chinese restaurants in the area. Clustering the POIs (Point of Interests) might help this.

1In [24]:
2from folium.plugins import MarkerCluster
1In [25]:
2# Define the marker cluster
3mc = MarkerCluster()
5# add a grey circle to represent the search radius
7    [lat_center, lon_center],
8    radius=search_radius,
9    color='#004B7F', # Navy
10    opacity=0.3,
11    fill = False
14# Add POIs one by one to the map
15for poi in result['results']:
16    mc.add_child(
17        folium.Marker(
18            location=tuple(poi['position'].values()),
19            popup=str(poi['poi']['name'])
20    ))
1Out [25:]

4.4. Key Takeaways

Now that I have investigated options for Linda through multiple filters and criteria, I can conclude:

  • There must be at least one existing Chinese restaurant in or near the neighborhood. If there isn't at least one Chinese restaurant, it might mean that there is not enough demand. Opening a Chinese restaurant without understanding why there are no any could be a risk for Linda.

  • There cannot be more than 10 existing Chinese restaurants in the neighborhood, in order to mitigate competition for her. Linda wants to stand out!

If I apply the criteria from the above map, I can exclude these neighborhoods:

  • Too many existing Chinese restaurants:

    • Nieuwmarkt

  • No existing Chinese restaurant in or near the neighborhood:

    • Weesperzijde

    • Frederik Hendrikbuurt

    • Grachtengordel-West

    • Nieuwe Pijp

The remaining neighborhoods left for Linda to choose from:

  • Jordaan

  • Van Lennepbuurt

  • Oude Pijp

  • Kinkerbuurt

  • Helmersbuurt

[5. In-depth analysis of one neighborhood]

Let's use Jordaan as an example to show how I look into one particular candidate neighborhood.

5.1. Draw the area of the neighborhood on the map

1In [26]:
2area_name = 'Jordaan'

Define a function to get polygon of a given GeoID.

1In [27]:
2# get polygon of GeoID: 
3def getPolygon(api_key,GeoID,zoomLevel):
5    url = 'https://api.tomtom.com/search/2/additionalData.json?geometries=' + GeoID
6    url += '&geometriesZoom=' + str(zoomLevel)
7    url += '&key=' + api_key
9    result = requests.get(url).json()    
10    GeoJson = result['additionalData'][0]['geometryData']
12    return GeoJson
1In [28]:
2# Search City:
3GeoID, position = SearchCity(api_key, area_name ,'Amsterdam')
1In [29]:
2lat_area = position['lat']
3lon_area = position['lon']
4print("The center of the neighborhood is: (", lat_area, ", ", lon_area, ")")

The center of the neighborhood is: (52.37329 , 4.87992).

Draw the polygon:

1In [30]:
2# Get Polygon of city:
3Polygon = getPolygon(api_key,GeoID,22)
1In [31]:
2map_url = 'http://{s}.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.png?view=Unified&key=' + api_key
4TomTom_map = folium.Map(
5   location=[lat_area, lon_area],
6   zoom_start=14,
7   tiles= map_url,
8   attr='TomTom')
10# add polygons to a map
12    Polygon).add_to(TomTom_map)
1[Out] 31:
Add geofences to your map with TomTom Maps API and SDK

5.2. Show Chinese restaurants in this neighborhood

Search for the Chinese restaurant using the Search API. Set the search radius to 1.2 km to cover the entire neighborhood.

1In [32]:
2url = ('https://api.tomtom.com/search/2/categorySearch/Chinese restaurant.json?countrySet=NL'
3       +'&lat=52.37329&lon=4.87992&limit=2000&radius=1200&key=' + api_key)
4result = requests.get(url).json()
1In [33]:
2# add a grey circle to represent the search radius
4    [lat_area, lon_area],
5    radius=1200,
6    color='#004B7F', # Navy
7    opacity=0.3,
8    fill = False
11# Add POIs one by one to the map
12for poi in result['results']:
13    folium.Marker(location=tuple(poi['position'].values()),
14                  popup=str(poi['poi']['name']), 
15                  icon=folium.Icon(color='blue', icon='glyphicon-star')
16                  #icon=icon
17             ).add_to(TomTom_map)
1Out [33]:
Show local Chinese restaurants using TomTom Maps APIs

Legends of the above map:

  • Blue markers: Chinese restaurants.

  • Blue area: The shape of the neighborhood.

  • Grey circle: the search radius.

Takeaways from this Neighborhood:

  • According to TomTom Map Display API, there are more than 20 Chinese Restaurants within the range of 500 meters of the neighborhood Jordaan.

  • From the map I learn that the west of Jordaan seems to be void of Chinese restaurants. If Linda opens a Chinese restaurant there, she will likely have enough customers.

5.3. Repeat!

At this point, I would advise Linda to repeat this in-depth examination for each neighborhood she is considering. I could also adjust the details. I consider to include other venues, for example – looking at the number of cafes, snack bars, etc present in an area in addition to regular restaurants.

[6. Conclusion and future work]

The Limitation of this Project

It only focuses on residential information. This project is limited by the lack of crucial information. So far I have been focused quite a lot on residence information and one-person households. However, customers can also come from nearby business venues. I am unable to validate any assumption or answer any questions, because the information of business venues in Amsterdam is not as available as demographic information.

Rent of a Venue is not Taken into Consideration

Due to lack of information, I am unable to include rental price as part of the analysis. Cost could be a big factor for Linda. In order to be able to predict the potential profit, however, it is crucial to include potential rental price.

Explore more POI Categories

There are other facilities in the neighborhood which may influence the income of the restaurant. For instance:

  • How easy is it to reach the place via public transportation?

    • Search for nearby bus stops, tram stations, train stations, etc.

  • How easy is it to park your car in the neighborhood?

    • Search for nearby parking garages or open parking places.

6.1 Next steps for Linda:

  • Continue to perform the same in-depth analysis to all neighborhoods as I did in here.

  • Include rental price of each neighborhood in future analysis to be informed about her costs to profit ratio.

Get the developer newsletter.
No marketing fuff. Tech content only.

* Required field. By submitting your contact details to TomTom, you agree that we can contact you about marketing offers, newsletters, or to invite you to webinars and events. We could further personalize the content that you receive via cookies. You can unsubscribe at any time by the link included in our emails. Review our privacy policy.