Building a WiFi spots Map of networks around you with WiGLE and RAMRBlockedUnblockFollowFollowingFeb 19It’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 .
Toolkitwiglr R Package for interfacing with WiGLE APIWiGLE API for data collectiontidyverse R Package for Data Analysis & Manipulationleaflet 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.
PrerequisitesBefore 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 packageswiglr 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 availabledevtools::install_github(“hrbrmstr/wiglr”)Other utility packages mentioned above:install.
packages('tidyverse') # ideally dplyr is what we'd needinstall.
packages('leaflet') Getting WiGLE API TokenCreate your account on wigle.
netAfter 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!Take-offLoading LibrariesAs with every other R project, the first step is to load all the required libraries.
library(wiglr)library(tidyverse)library(leaflet)General Statistics of spots around usIn 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'rewifi_box <- wigle_bbox_search(12.
8431) Sample Output> wifi_box$success TRUE$totalResults 252098$search_after 552772$first 1$last 100$resultCount 100$results# 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.
6 oakd… 0 201701… 6 2017-01-… 2017-01… 2017-01… 305, 1st M… 2 12.
6 Sham… 0 201606… 11 2001-01-… 2016-06… 2016-06… "" 3 13.
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 .
CruiseWith 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", ifelse( wifi_box$results$encryption == "unknown", "yellow","blue")))This gives us this nice plot (which is interactive in nature when you plot in your RStudio)You can play around with different values of names(providers)to pick the preferred Base-layer / Map theme.
Safe LandingWith that, we’ve successfully plotted the WiFi Networks around us — along with its SSID and Security Encryption.
This is highly useful in detecting and notifying Open Networks with no security which could be attacked by Malicious parties.
ReferencesIn Dev: WiGLE Your Way Into A Hotspot with wiglrComplete Code used here on my githubWiGLE Official SiteClosing Notes: If you are interested in contributing to open source, Contribute to this package to successfully deploy on CRAN so it can reach masses.