Experimentation with geospatial mapping
Recently I experimented with geospatial mapping techniques in R. I looked at both static and interactive maps. Embedding the media into a WordPress blog would be simple enough with a static map. The latter would require (for me) a new technique to retain the interactivity inside a blog post.
My web-site visitor log, combined with longitude and latitude data from MaxMind’s GeoLite2, offered a basis for analysis. Although less precise than the GeoIP2 database, this would be more than adequate for my purpose of getting to country and city level. I settled on the Leaflet package for visualisation given the interactivity and pleasing choice of aesthetics.
The results however were a little puzzling.
Whiling away the hours in Kansas
The concentration of page views in central London was of no immediate surprise as this was likely to be my site building, testing, and blogging. What did strike me as odd was the high concentration of page views in the centre of the US. More curious still, when I zoomed in on Kansas and found myself in the middle of the Cheney Reservoir.

I imagined someone drifting in the expanse of water with laptop, flask of coffee and box of sandwiches, whiling away the hours absorbed in my blog. Perhaps not. How could such a small number of blog pages generate in excess of 2,000 page views in less than two months?
Then I chanced upon a BBC news article from August 2016. When unable to locate IPs, MaxMind chose the geographical centre of the US as a default. This initially turned out to be a rented house in Kansas, which was rather unfortunate for the occupants, and brought upon them all kinds of unwanted attention.
MaxMind subsequently changed its default centre points to be the middle of bodies of water. And this solved another puzzle. Some of the page views in London appeared to be in the middle of the River Thames.
R toolkit
Packages | Functions | |
---|---|---|
![]() | purrr | map[1]; map2_df[1]; negate[1]; possibly[1]; set_names[1] |
furrr | future_map2_dfr[1] | |
future | multiprocess[1]; plan[1] | |
![]() | readr | read_csv[1]; read_lines[1] |
rgeolocate | maxmind[1] | |
rgdal | readOGR[1] | |
R.oo | Package[1] | |
R.utils | gunzip[1]; R.utils[1] | |
![]() | dplyr | if_else[6]; mutate[6]; filter[5]; arrange[2]; case_when[2]; tibble[2]; as_tibble[1]; desc[1]; group_by[1]; rename[1]; select[1]; summarise[1] |
stringr | str_c[3]; str_detect[3]; fixed[1]; str_count[1]; str_remove[1]; str_remove_all[1] | |
base | library[12]; c[6]; function[2]; is.na[2]; as.character[1]; basename[1]; conflicts[1]; cumsum[1]; getwd[1]; list[1]; search[1]; sum[1] | |
rebus | literal[4]; lookahead[3]; whole_word[2]; ALPHA[1]; lookbehind[1]; one_or_more[1]; or[1] | |
tibble | enframe[1] | |
knitr | current_input[1] | |
tidyr | unnest[1] | |
utils | download.file[2]; unzip[1] | |
![]() | leaflet | leaflet[2]; addCircleMarkers[1]; addLegend[1]; addPolygons[1]; addProviderTiles[1]; colorFactor[1]; highlightOptions[1]; labelOptions[1]; providerTileOptions[1]; setView[1] |
htmlwidgets | saveWidget[1] | |
kableExtra | kable[1]; kable_styling[1] |
The code may be viewed here.
Great post! I don’t want to destroy the wonder and mystery of the world around us, but, behold! My IP address according to a site where I registered (or anything public facing)
https://i.imgur.com/VvKcuAK.png
It’s where Comcast says you are if you don’t want to fork over your location info!
Location
37.7510,-97.8220
US
Organization
AS7922 Comcast Cable Communications, LLC
Ah, so it’s you in the boat 🙂