Tag Archives: Street Level Maps

Another Update on my Ubuntu Experiment

Environments are important. Whether it’s having the right desk and office chair, the perfect office or where you chose to live, my emotional satisfaction and motivations are impacted by my environment. It doesn’t matter whether you work solo or in a small group, your environment affects how you work and how well you work. I clearly remember driving to work on I270 in Columbus, bumper-to-bumper traffic and arriving at work in such a foul mood because of the commute. I moved to Grand Rapids, MI and there experienced cold overcast skies and lots of snow. I learned that I was suffering from SAD (Seasonal Affective Disorder.) I was able to change that for myself years ago, but the same principles apply whether you are looking at your work-flow and perhaps your workstation environment as it pertains productivity and satisfaction.

clip_image002

Lessons learned, my commute today… Home office to patio and a lot less stress.

Another month has passed since I went over to Ubuntu as my primary OS as wanted to get back to those who may be wondering how it has gone. I must say, even with a five year-old mediocre laptop, it has gone better than I thought it would. Almost every wound I have suffered has been self inflicted.

Am I as efficient and effective as with my Windows machine? The answer is “yes.” Programming in WPS and surfing the internet has been the same experience as with my Windows machines. I have gone back to my Windows PC for bookkeeping chores when I needed. I chose not to try to move that application for this experiment. I considered it too much work and out-of-scope.

Since I started this experiment, Canonical has decided that they are going to drop their GUI interface called Unity and return to Gnome. Unity it seems, was a project that was designed to “unify” the Ubuntu experience across platforms such as tablets, phones, laptops and workstations. From my reading, the decision was made to stop the financial hemorrhaging and focus on workstations and servers at the expense of phones and tablets. I actually found Unity easy to use and not a hindrance at all.

I can understand and appreciate the reasons for that decision however. Mark Shuttleworth (founder and CEO) wrote a blog post on how and why he came to that decision. Basically, Canonical is a business (not a charitable organization) and he is treating it as such. Move to your strengths and develop those areas where the revenue stream is best.

But back to my Ubuntu experiment. I could go through each application that I use and talk about the anomalies that I discovered but that would be really boring. But suffice to say, that using LibreOffice was decent and a good enough replacement for MS Word. LibreOffice Calc was good enough for my spreadsheet needs as well. I did suffer using MS OneNote a bit. I’m a huge advocate of using OneNote to keep my ideas, plans and outlines in one place. It’s one of my go-to applications.

The issue I have with OneNote is using the online version. Unexplainably, it would insert extra space between words or even letters at random. It wouldn’t do it often, but often enough to be irritating. Perhaps it is the browser I used and I should try OneNote with a different browser.

I’ve been writing a vertical market application over the last four to six months in my free time. This is a street mapping application using R, Google Maps and WPS. WPS has worked like a champ on Ubuntu Linux. Everything I threw at it worked straight away. The Eclipse workbench is exactly the same as you would see when on Windows. As a matter of fact, I like the font used by Eclipse better than the one on Windows.

clip_image004

By the way, the screen shot you see above that has the WPS Workbench displayed – this is the exact same interface you see and use with WPS Link on Linux. WPS Link is the “thin client” that World Programming distributes with their server software which allows users to interactively access the WPS software as if it was running on their desktop.

So, the question to be answered is “Can I move away from using Windows as my only OS platform for everyday use?” The answer to that is “yes.” I will most likely purchase a Dell Laptop that has Ubuntu pre-installed this summer and use that as my primary development workstation. I will keep a Windows workstation so I can test and develop on that platform as well. However, now that Skype is running decently on Ubuntu, there is no reason that I can find to not use Ubuntu. What do I give up other than forced reboots and forced updates? Not much…

About the author: Phil Rack is President of MineQuest Business Analytics, LLC located in beautiful Tucson, Arizona. Phil has been a SAS language developer for more than 25 years. MineQuest provides WPS consulting and contract programming services and is an authorized reseller of WPS in North America.

Plotting Points on a Street Level Map using the Bridge to R and WPS

In the last few installments of this blog, I have shown how you can use WPS and the Bridge to R to calculate drive distances, geocode records and pull down a map from Google maps. I want to use this post to pull all this together and show how you can geocode your addresses and plot them on a street level map.

First some background you need to know about using Google for geocoding and mapping. There are limits to what Google will allow you to do with their services before they want you to start paying. You can geocode 2,500 records a day for free. You can pull down 25,000 maps a day for free. Once you start moving past these limits, there are fees involved.

One thing that you should probably start to consider is caching records locally that have been geocoded so that you don’t have to go back to the Google geocoder every time you want to plot some points on a map. I could easily run through 2,500 addresses in a day. The limitations on the number of maps is just not an issue for me. I think 25,000 maps a day is a very liberal offering for the kind of work that I would want to use the service for.

In the sample code below, I split the mapping process into two components for ease in understanding the entire process. I first geocode the file to get the latitude and longitude for each record. The second part of the process is creating a map and using the lat’s and long’s to plot points on the map. We could have put this into a single step but it wouldn’t be as clear or as flexible.

Without further ado, here’s the code using the Bridge to R and WPS.

data gasstations;
input company $1-29 address $30-52 city $53-64 state $66-67;
addr2geocode=trim(address)||', '||trim(city)||', '||trim(state);
cards;
Citgo Gas Station            5189 28th St Se        Grand Rapids MI
28th Street BP               5155 28th St Se        Grand Rapids MI
Twenty-Eighth Street C Store 5556 28th St Se        Grand Rapids MI
Speedway                     4045 28th St Se        Grand Rapids MI
Speedway                     2305 E Paris Ave Se    Grand Rapids MI
Superamerica                 2305 E Paris Ave Se    Grand Rapids MI
Shell Food Mart              3960 28th St Se        Grand Rapids MI
Admiral Petroleum            3927 28th St Se        Grand Rapids MI
Cascade C Store              4591 Cascade Rd Se     Grand Rapids MI
Friendly Food Shops          6799 Cascade Rd Se     Grand Rapids MI
Family Fare Quick Stop       6799 Cascade Rd Se     Grand Rapids MI
Cascade Citgo                6820 Cascade Rd Se     Grand Rapids MI
Dutton Fuel Mart LLC         2560 E Beltline Ave Se Grand Rapids MI
Centerpointe Marathon        2560 E Beltline Ave Se Grand Rapids MI
Shell Food Mart              2600 E Beltline Ave Se Grand Rapids MI
Speedway                     4018 Cascade Rd Se     Grand Rapids MI
Grand Rapids Gas Incorporated3214 28th St Se        Grand Rapids MI
Cascade Shell                4033 Cascade Rd Se     Grand Rapids MI
Speedway                     4665 44th St Se        Kentwood     MI
Super Petroleum Incorporated 2411 28th St Se        Grand Rapids MI
;;;;
run;


*--> Geocode the addresses using the Google Geocoder. Keep the geocoded records
     in the output dataset names locs for further processing.;

%rstart(dataformat=csv,data=gasstations,rGraphicsFile=);
datalines4;

## options(repos=structure(c(CRAN="http://cran.case.edu/")))
## install.packages("ggmap", dependencies = FALSE)

   attach(gasstations)

   library(ggmap)

   gaddress <- as.character(gasstations$addr2geocode)
   locs <- geocode(gaddress,output="more")

;;;;
%rstop(import=locs);


*--> Pull a Google map that is centered on a particular address and plot the locations
     on the map. Use the data set that was created (locs) above that contains the 
     lat and longs to plot the points.;
     
Title 'Gas Stations on or Near 28th Street';
Title2 'Grand Rapids, Michigan';     
     
%rstart(dataformat=csv,data=locs,rGraphicsFile=);
datalines4;

attach(locs)
addr <- locs;

library(ggmap)

map.center <- geocode('3960 28th St Se, Grand Rapids, MI');

 grmap <- qmap(c(lon=map.center$lon, lat=map.center$lat), zoom = 13,color = 'color', legend = 'topleft')
          grmap +geom_point(aes(x = lon, y = lat, size=3.0), data = addr)

;;;;
%rstop(import=);

The map that is created looks like this:

GR_Stations

I cropped this down a bit and got rid of the borders so that it would be easier to view on this blog. Note the black points on the map that indicate the locations of the gas stations. We could continue this exercise by plotting a label to the points with the names of the service stations but that would be a good exercise for the reader who wants to learn more about using ggmap and street level mapping.

If you want to learn more about ggmap and street level mapping, I encourage you to take a look at the following document, “ggmap: Spatial Visualization with ggplot2 – the R Journal” and can be viewed in PDF format here. What I have presented is really a quick and dirty set of examples that just begin to scratch the surface of what ggmap can do for you.

About the author: Phil Rack is President of MineQuest Business Analytics, LLC located in Grand Rapids, Michigan. Phil has been a SAS language developer for more than 25 years. MineQuest provides WPS and SAS consulting and contract programming services and is a authorized reseller of WPS in North America.