Building a WiFi spots Map of networks around you with WiGLE and R

It’s always fun to explore the world around us — that’s even more fun when you get to explore the world with the Vision of a Data Scientist.

In this analysis, We are going to identify the open WiFi Networks around us and map them on an interactive map .


  • wiglr R Package for interfacing with WiGLE API
  • WiGLE API for data collection
  • tidyverse R Package for Data Analysis & Manipulation
  • leaflet R Package for drawing interactive maps (interface to leaflet.js)

wiglr is an R-package that’s (under-development) been developed by Bob Rudis who goes by the name hrbrmstr. He is one of the power-users of R who’s also actively involved in developing new R packages and blogging about those.


Before we start with the coding (which is anyways, just a bunch of lines), we need to do two important things.

Install all the required R packages

wiglr is not yet available on CRAN hence has to be installed from Github/Gitlab based on your preference. Below is the code, how you can install it from Github using devtools package

# install.packages('devtools') # install devtools if not available

Other utility packages mentioned above:

install.packages('tidyverse') # ideally dplyr is what we'd need

Getting WiGLE API Token

  • Create your account on
  • After logging in, Get your API token from your account page (clicking Show Token)
  • Open RStudio and Set your (“Encoded for use”) API Token as an environment variable like this:
Sys.setenv(WIGLE_API_KEY = "here_goes_my_encoded_token")

With that, we’re good with our prerequisites and ready to take off!


Loading Libraries

As with every other R project, the first step is to load all the required libraries.


General Statistics of spots around us

In this step, we’ll give bounding box (in the form Latitudes and Longitudes) and extract the detail of WiFi networks around us.

# This is for Bengaluru, India - change it according to where you're
wifi_box <- wigle_bbox_search(12.7585, 13.1105, 77.5477, 77.8431)

Sample Output

> wifi_box
[1] TRUE
[1] 252098
[1] 552772
[1] 1
[1] 100
[1] 100
# A tibble: 100 x 25
trilat trilong ssid qos transid channel firsttime lasttime lastupdt housenumber
* <dbl> <dbl> <chr> <int> <chr> <int> <chr> <chr> <chr> <chr>
1 12.9 77.6 oakd… 0 201701… 6 2017-01-… 2017-01… 2017-01… 305, 1st M…
2 12.9 77.6 Sham… 0 201606… 11 2001-01-… 2016-06… 2016-06… ""
3 13.0 77.7 PPAN… 0 201303… 1 2013-03-… 2013-03… 2013-03… ""

It’s just a list (the output of a JSON response) with actual result and some meta. As you can see in the above sample output, our focus area would be the results .


With that, It’s time to draw the interactive map that we promised to draw (at the start of this article).

Below is the code where we take the results from wifi_box and create a new variable labs (which would be used in the further lines for popup labels). This data is further fed into leaflet() for map creation where we add a base layer and then add Circle Markers at the given Longitudes and Latitudes.

The color coding is for us to denote if the Security of the WiFi network is none (no security) — Red, unknown — Yellow and everything else (like WEP, WPA) — Blue.

wifi_box$results %>% 
mutate(labs = sprintf("SSID: <code>%s</code><br/>Encryption: %s", ssid, encryption)) %>%
leaflet() %>%
#addTiles() %>%
addProviderTiles(providers$Stamen.Toner) %>%
#addProviderTiles(providers$OpenStreetMap, options = providerTileOptions(opacity = 0.4)) %>%
addCircleMarkers(~trilong, ~trilat,
radius = 10,
popup = ~labs,
color = ifelse(
wifi_box$results$encryption == "none","red",
wifi_box$results$encryption == "unknown",

This gives us this nice plot (which is interactive in nature when you plot in your RStudio)


Leave a Comment