Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
On my trip to Japan, I took this photo of the stairs leading to the “Rucker Park of Tokyo.” I crossed up some Tokyo cats, they were garbage. That one girl behind the blue pillar was practicing her hip hop power moves. She thought no one could see, but I saw.
I’ve been traveling. I’ve been starring places on google maps. I want to share my recs with friends. I also want to receive recs from friends. See this wired article that came out today!
ONE DUMB SNAG: YOU CAN NOT DO THIS SMOOTHLY USING PURE GOOGLE TOOLS
“Google Maps” (what you use on the phone) exports ‘.json’ data
yet
“Google My Maps” (what you share with friends) CANNOT import ‘.json’ data
https://productforums.google.com/forum/#!topic/maps/Ms6ouQuA4qI
For something like this, Gavin Belson would rip a new hole in some unsuspecting Hooli employee. I really hope the engineers of “Google (My) Maps” eventually roll out a backend feature that would make this post obsolete.
DUMB SNAG ELIMINATOR: #RSTATS IS AWESOME
This is why you’re here, we’re going to fill the middle gap with a very easy #rstats script.
Step 1) Google Takeout > Google My Maps > export json
Step 2) Use R to manipulate json then export a csv spreadsheet
R:::jsonlite::fromJSON()
R:::dplyr::filter()
R:::base::write.csv()
Step 3) Google My Maps > Upload csv spreadsheet via Drag + Drop
https://support.google.com/mymaps/answer/3024925?rd=1
Step 4) Share the url link of your new map with friends
Here’s my Google My Maps of Japan
Spread the word, use this method, play a game of around the world… around the world 😉 , and share your recs.
Shoutouts to Slow Magic and O-nest in Shibuya
HERE IS THE MEAT OF THE #RSTATS CODE FOR STEP 2 (ABOVE). LOOK AT HOW SHORT AND ‘HUMAN-READABLE’ THE SYNTAX IS.
library(jsonlite) library(dplyr) # read in .json data # Google -> Takeout -> Google Maps (My Places) -> Saved Places.json # https://en.wikipedia.org/wiki/Google_Takeout txt = '~/projects/Saved Places.json' dat = fromJSON(txt, flatten = TRUE) # keep the useful parts df_feat = flatten(dat$features) df_dat = df_feat %>% select(`properties.Location.Business Name`, `properties.Location.Address`, `properties.Location.Geo Coordinates.Latitude`, `properties.Location.Geo Coordinates.Longitude` ) # subset to specific geographies # method 1, grep for state in address (easier) dat_jap = df_dat %>% filter(grepl(pattern='Japan',x=properties.Location.Address)) # export to a csv spreadsheet write.csv(dat_jap,file='~/projects//dat_jap.csv',row.names=FALSE) # upload csv into Google My Maps to share
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.