Showing posts with label GoogleVis. Show all posts
Showing posts with label GoogleVis. Show all posts

GoogleVis Limitations

Now finding GoogleVis is a major discovery for me but I encoutered two problems with this tool:
1- Since my data is in other coordinate systems, I need to transform it into WGS84 so that it is overlayable on the Google maps. My data are the point data (referring to the house positions) so it is really awkward to see a point on Google map refereing to a house location to be shown on road or empty land!. I had the same problem overlaying my data on the Google Earth/Maps and it seems that it is the end of the road for me on that issue unless I find a way to do the corrections in the coordinates! .. have to brush up my GIS knowledge.
2- The even bigger problem is the problem of limitation on the number of points or entities your can do overlay on. It is only 400 points to be more exact. So if you have more than that, the function will truncate the data set and will show a prompt on the top left of your map screen about that. I think this is a limitation from the Google server.
If I can solve my first problem, then I will try to find a way to solve the second problem too. But the first problem is more dire.
I am looking to find a platform so that I can have my map shown then the results of analysis are shown on the map (most likely in the form of points) and then here comes the "inter-active" parts so that the user can click on the points and get the information. Further I think I will need to find a way to give the user the freedom to change the attributes and see the results of that online.....

The magnificent GoogleVis

We can find a (Google) map on almost any website and blog these days. And we are so lucky that companies like Google took the initiative to create good maps and their associated interfaces like Google Earth. But I think the best contribution is the ability to overlay results of analysis on the Google maps. Several API's have been developed to do this kinds of works. For my goal I found an API named "Google Chart Tools, formerly known as Google Visualisation API" and a R package that gives you the ability to overlay your results on the Google maps. I found it to be usefull to overlays some of the results on beautiful maps from Google (finding a good map that you can overlay your results could give you a headache!). Below I summarize the things that are needed to overlay your point based results:
1- Read your data into R as a data frame.
2- Create filed or column called "LatLong" in that data frame that binds the latitudes and longitudes as a string character in this way: "lat:long".
Tip: If your data is projected you need to transform your coordinates and remember the X is longitude!.
3- Use the function gvisMap() that only needs 3 arguments (name of data frame, "latlong", "a column name in your data frame") to create your HTML output.
4- Use plot() command to fire up the browser and show the over lay. (Example below:)
//--> -->
Data: Map • Chart ID: GeoMapIDd5479cd4481
R version 2.15.1 (2012-06-22) • googleVis-0.3.1Google Terms of UseData Policy

Here is the code for the above example (I took it from the package help page):

library(googleVis)
 
input<- read.csv("data.csv")
 
select<- input[which(input$Subgroup=="Total 5-14"),]
 
select<- input[which(input$Subgroup=="Total 5-14 yr"),]
 
Map<- data.frame(select$Country.or.Area, select$Value)
 
names(Map)<- c("Country", "Percentage")
 
Geo=gvisGeoMap(Map, locationvar="Country", numvar="Percentage",
options=list(height=350, dataMode='regions'))
print(Geo, file="Andrew.html") #copy and paste the content of this html file (between the \body tags) into your blogger post or other websites.
plot(Geo)
Created by Pretty R at inside-R.org

In the next post I will discuss the downside of the GoogleVis for me!.