JULY 26, 2022

R Mapping and Leaflet

By Siddhant Singh

Share

So recently we got this project where we have to build some of the features on top of Maps.
We have spent around two weeks building features like Clustering, Heatmap, Geo-boundaries, Filtering, Google Search and some nice UI with the help of Shiny. 

Why do we choose R and Shiny?

It has great support for libraries like 


a. Leaflet :- It’s an open source Javascript library for interactive maps and R packages make it easy to create Leaflet from R


b. Dplyr :- dplyr is a grammar of data manipulation, providing a consistent set of verbs that help you solve the most common data manipulation challenges like select, filter, arrange, mutate. 

c. Shiny and Shiny Dashboard:- Shiny provides us all the UI functionality with some inbuilt function and separates the logic from the server. 

d. googleway :-  It provides the various access for the google apis within your map. 


Let’s talk about the use case

One of the use cases to represent the points on the map where all these common problems occur. Like the number of potholes in a particular area and the data set which we took has some locations which have certain information like  Longitude, Latitude, Village, Category, Address, Description, District Name etc. 


Categories can represent different things like Potholes in some area and then similarly we can check Air Quality.

Features which have worked on

  1. Clustering

To represent this data on Map we created a cluster of the data points and it looks something like this:-

2. HeatMap

The second use case where the data can be shown through heatmap. It provides graphical representation of data using colors to visualize the data points.

3. Card View

Then we also focused on the data points where we can show the detailed information about the data points. This functionally also you can do using the leaflet library. In this popup you can see a card view which shows multiple information about the particular data point. We also manage to add the image.  

4. Google Search

Next feature is to find a way to integrate google api’s into this. We managed to find a great library for that. Googleway has an inbuilt function which you can use to integrate with this. Of course, you need a google credentials api key and also you need to enable google map api in order to use it. 

We use this feature to search a particular location data points. As we are showing here that I need a datapoints for the mumbai.

So this is what we have been doing for a couple of weeks. There’s a lot to fix and improve. Will address it one at a time. Meanwhile please give us feedback.

What next

a. We will show you how to add geo boundaries on the map.
b. Then we will add different filters like state and district related data points.
c. The big question we will address is if it can handle mobile view.
d. We will also show how to add different categories to data points.

Leave a Reply

Recommended reading

7 Things you must know about using WhatsApp chatbot

Here are a few things you should note when planning to use WhatsApp...

JULY 18, 2022

Integrating Google Sheets in Glific

Integrating Google Sheets in GlificWhile building Glific for the past 2.5 years, one...

OCTOBER 21, 2022

Google sheet integration: Early stages

Need In today’s world, if you want to save any relational data quickly...

OCTOBER 21, 2022

Database synchronisation with Bigquery (In Elixir)

Data can play an important role for social sector organisations by helping them...

OCTOBER 10, 2022

%d bloggers like this: