Tuesday, January 28, 2020

Brunswick Vs NZ Cities: The Sushi Challenge.

This post constitutes my final report for the IBM Applied Data Science Capstone course, as part of the IBM Data Science Professional Certificate.


The goal of this report was to demonstrate my ability to clearly define a problem that could be solved using location data, and then make calls to API's and use the data to solve the problem.

The code used to develop this report is available on my Github.


Introduction


I moved from Auckland, New Zealand to Brunswick, Melbourne, Australia, 6 years ago.

Both my parents (who live in Hamilton, NZ) and my parents-in-law (who live in Christchurch, NZ), are constantly asking me when I will move back home with my family.

There are many considerations about where to move to if I do head back to NZ, but since my favourite food is sushi, which of the 4 largest New Zealand cities should I live in, if I want to live in the center city and maximize my options for eating sushi within a walk-able 1.5 km zone?

Additionally, where would be the optimum location to find a house or apartment so that I was living in the center of these sushi venues?




I am only comparing the 4 largest cities in New Zealand to the City of Moreland (which encompasses Brunswick), as Moreland's population size in 2016 of 162,558 would make it the fourth largest city in New Zealand at that time.

The population of each of the four largest New Zealand cities in 2016 were as follows:


  • Auckland: 1 614 300   
  • Christchurch: 375 000   
  • Wellington: 207 900   
  • Hamilton: 161 200   
Obviously the audience for this analysis is focused on my own needs, but is also valuable to anyone else who loves sushi and will be visiting these five cities and staying centrally.


Data


I will use the Foursquare API's "venue", "category ID" and location data to compare the availability of sushi restaurants in my local city of Brunswick, located in Moreland to the four largest cities in New Zealand: Auckland, Wellington, Christchurch and Hamilton.

The data on population size was gathered from the Australian Bureau of Statistics' 2016 Census Data and Statistics New Zealand's 2016 Subnational Population  Estimates .

The restaurant data will be gathered only from venues within a radius of 1.5 km from the each cities' center coordinates, as defined by Foursquare.


Methodology


I used Google Colab to create the notebook for this project. All code was written in Python 3.0.

To find all of the sushi restaurants in each city within a 1.5 km radius of the city centers, requests were sent to the Foursquare API using the following the format:

url = 'https://api.foursquare.com/v2/venues/explore?&client_id={}&client_secret={}&v={}&near={}&limit={}&radius={}&categoryId={}'.format(CLIENT_ID,CLIENT_SECRET,VERSION,city,LIMIT,radius,"4bf58dd8d48988d1d2941735")

Where the category ID was "4bf58dd8d48988d1d2941735" codes for 'sushi' in Foursquare.

The results were put into a data frame containing each cities' sushi venues' name, latitude and longitude, example below:



To determine which city had the most sushi restaurants within the defined 1.5 km radius, the total result for each query was tallied.

The python folium library was then used to visualize the location of each sushi venue in each city.

To determine the location that would be best suited to find a house or apartment in each city that would be the most central to all of the sushi venues, the mean latitude and longitude of the sushi venues was determined and then added to the map of each city, with lines leading to each venue.


Results


The number of sushi venues in each city, within a 1.5 km radius of the city center, were as follows:



  • Brunswick (54)
  • Auckland (46)
  • Wellington (35)
  • Hamilton (18)
  • Christchurch (8)


The locations that would be most beneficial to find a house or apartment, in order to minimize the average distance to each sushi venue, were as follows:



  • Brunswick [-37.789369092799696, 144.96825665600176]
  • Auckland [-36.85871458790793, 174.76689561211802]
  • Wellington [-41.287690684226455, 174.77693456845236]
  • Christchurch [-43.535147979870764, 172.63369264456878]
  • Hamilton [-43.535147979870764, 172.63369264456878]


These optimum living locations, with lines to each individual sushi venue, are visualised in the below maps:


Sushi venues within 1.5 km of Brunswick marked in blue, with the optimum living coordinates marked in a green circle.


Sushi venues within 1.5 km of Auckland city centre marked in blue, with the optimum living coordinates marked in a green circle.


Sushi venues within 1.5 km of Wellington City centre marked in blue, with the optimum living coordinates marked in a green circle.
Sushi venues within 1.5 km of Christchurch city centre marked in blue, with the optimum living coordinates marked in a green circle.
Sushi venues within 1.5 km of Hamilton city centre marked in blue, with the optimum living coordinates marked in a green circle.

Discussion


It makes sense that there are more sushi venues available close to my current location of Brunswick than for any of the New Zealand city centres, as the wider Melbourne population is far higher than any of the New Zealand cities examined here.

For future analysis I would enhance the transparency of the requests by including the location of the "City Centre" as defined by Foursquare on the map, to ascertain that it matches with the city centre as defined by local planning.

Given the population size of Christchurch I would have expected it to contain more sushi venues. As it is the only city located within the South Island of New Zealand, perhaps the cultural demographics differ compared to those in the North Island, which could be looked into in future studies.



Conclusion


In conclusion, it seems that if I were to choose a New Zealand city to move to, based solely on the number of sushi restaurants close to the city center, I would be moving back to my old home town of Auckland. Based on the mean location of sushi restaurants, I would ideally looking for a place to live in Grafton.

If I was looking to move closer to family as a secondary consideration, my parents will be happier than my partners', as Hamilton has more centrally located sushi restaurants than Christchurch.

Finally, I now know that I currently live 2.4 km north of my ideal sushi-based living zone, so if I'm looking to move in Melbourne I know where to focus my house search.