The world’s leading publication for data science, AI, and ML professionals.

The location analytics “thought process”

How you need to think while doing location analytics

Photo by Element5 Digital on Unsplash
Photo by Element5 Digital on Unsplash

Imagine you are part of a ‘life-and-death’ Squid-game (Netflix show) style game. You have to choose only two data fields that are present in most of the data around us. I can surely say with confidence that the two fields of Location data – latitude and longitude – can save you.

Ok, now that you have survived, let us continue with the very interesting topic of location analytics. In this story, I will describe the thought process you will need while working with location analytics.

Normally writers start with a beautiful visualization to attract the reader’s attention. But, please excuse me, as I am starting with a messy visualization.

Airbnb location in New York (image by the author using Google Maps)
Airbnb location in New York (image by the author using Google Maps)

So you may ask, what the heck is this visualization? Let me first answer this question. This visualization shows all Airbnb locations in New York. The objective is to analyze how the Airbnb locations are distributed over the city of New York.

Even though the objective of this analytics is reasonable, and there has been a lot of programming techniques, such as Google Map API /Javascript/Node-JS, have been involved, the result still looks messy. To make it worse, it takes a long time to load this visualization and possibly crash your browser.

Let’s see how Location Analytics can help avoid the mess. And as a reminder, our objective is to analyze how the Airbnb locations are distributed over the city of New York. Here is the thought process, which is useful in performing location analytics.

Understand the geography

While using location analytics, it is important to understand geography. This helps you understand the context. It might also require taking a quick geography lesson on the internet or other sources.

In our example, the geography which we want to analyze is New York. So here is a quick crash course on New York. Geographically, New York is a city with 5 boroughs, 59 community districts, and hundreds of neighborhoods.

Source - https://www1.nyc.gov/site/planning/data-maps/city-neighborhoods.page
Source – https://www1.nyc.gov/site/planning/data-maps/city-neighborhoods.page

You can go to the New York City website and understand the city’s geography. This time investment in studying geography will help you present your results in an efficient and engaging way.

Thinking geography in mathematical terms

Now that you have a rough understanding of geography, you need to start viewing it from a mathematical perspective. If you closely look at the map above, you see mathematical shapes, called polygons. And out of all mathematical shapes – squares, rectangles, triangles, etc… – the polygons are magic. As they can be literally used to represent any geographic area on earth.

Let us take an example of the neighborhood Morningside Heights. On the image below, on the left, you see the neighborhood on Google Maps. On the right-hand side, you see a mathematical polygon that has the same shape as the neighborhood Morningside Heights.

The geographic area as polygon (source Google-Maps)
The geographic area as polygon (source Google-Maps)

Now you can translate the polygon definition into latitude and longitudes. The polygon definition of neighborhood Morningside Heights would be something like this.

Polygon Definition of neighborhood Morningside Heights (image by author)
Polygon Definition of neighborhood Morningside Heights (image by author)

There are various sources that will allow you to get the polygon definition of any geography on earth. As an example, the polygon definition of all New York City neighborhoods is available on the city’s government website. Once you have all the polygon information, you can plot the polygons on a google map.

Shown below is a polygon map of each and every neighborhood in New York.

Polygon map of New York City (Source Google Map + Author)
Polygon map of New York City (Source Google Map + Author)

Once you achieve the polygon map of any geography, you will start feeling in control of any location analytics problem.

Applying Location Analytics Algorithm

Ok till now, you have understood geography and mastered its mathematical definition. So, you are only now at the stage where you can think of a location analytics algorithm.

And it is also the right time to rewind and recall our objective, which is to analyze how the Airbnb locations are distributed over the city of New York. Breaking it down means which parts (or neighborhoods) have more AirBnB locations than others. In analytical terms, this means which polygon has more latitude-longitude points compared to other polygons. This will require assigning a latitude-longitude point to a polygon.

One of the very useful location analytic algorithms is Point-In-Polygon. It will find the polygon which encapsulates a latitude-longitude point. Here is an animation of how different latitude-longitude points are assigned to different polygons

Point-Polygon Algorithm (Image source - Author)
Point-Polygon Algorithm (Image source – Author)

Choosing the right visualization

Almost all location analytics are eventually represented as map visualizations. However, they are not just a simple map of what we see while waiting for a Uber ride. They are more sophisticated as they need to encompass all intelligence worked out by location analytics algorithms.

In our case, the output of the point-in-polygon algorithm is neighborhood polygon definition and the number of Airbnb locations in the polygon. This data can help us superimpose a heat map over a geographical map. Ok, that is not a play of words, but both visualizations (heat-map and geographical-map) have the word ‘map’ in them.

So this is how a superimposed heat map over a geographical map would look like.

Heatmap over a geographic map (Source Google Map + Author)
Heatmap over a geographic map (Source Google Map + Author)

Beautiful! Much better than the messy visualization we started with. With this, we can clearly visualize which neighborhoods have more (red color) AirBnB locations compared to others (green color). As an example, you can see that Manhattan has fewer Airbnb locations. This is possibly due to the fact that it is an area that has more office buildings and not residential locations.

So in summary,

  • Location Analytics is not just using Latitude and Longitude, but using them along with some intelligent algorithms.
  • To efficiently use location analytics, it is important to spend time understanding the concerning geography.
  • Translating the geography into mathematical terms will require you to hunt for polygon definition data.
  • Choosing a location analytic algorithm should be done only after you have a grasp of geography and its mathematical definition.
  • Most of the location analytics will require visualization which goes beyond simple map display.

Additional resources

Website

You can visit my website to make analytics with zero coding. https://experiencedatascience.com

Please subscribe to stay informed whenever I release a new story.

Get an email whenever Pranay Dave publishes.

You can also join Medium with my referral link.

Join Medium with my referral link – Pranay Dave

Youtube channel Here is link to my YouTube channel https://www.youtube.com/c/DataScienceDemonstrated


Related Articles