Why I insist on having GIS functionalities in R?

There are a host of softwares that do GIS functionalities. Some of them are based on the image analysis and many of them are focusing on the spatial analysis. Some of them are proprietary and many are freeware and open source. A big chunk of "spatial analysis" capability in GIS is to do "statistical analysis" on the geographic data. This part has been neglected in many of the GIS softwares. Primarily due to the satisfying effect of maps on derivation of final conclusions about the spatial effects. This view however is increasingly changing as the assurances that a scientific conclusion and more importantly statistical analysis can provide for different dsiciplines is un-matched.
Among the most promising and free software for the spatial data analysis, R has emerged as the force to reckon with. The number of functions and formulas in the spatial analysis papers that can be used for data analysis is increasingly high in R (although other software like Goda are also very good in providing  functions for the analysis). However the nature of R which relies on two things community development and community help shows more promise. Over the past decade we have seen treamendous development in R spatial packages. These packages and functions although very useful, they need to be tested in the community and improved by the volunteer developers. As such, some of the primary functions of GIS are missing in R. For example despite rich facilities in R for visualization, a straiforward map representation and interactive map facility is missing in R. Some might say, it is not there because it shouldnt be there. R is statistical analysis software not a GIS. The answer to that I think is simply the promise of open source and power of community. If some people someday decide to add an inherent visaulizaiton capability to R it would not be a problem.
Some have developed a workaround for this problem which is the connection to the open source GIS software like SAGA, GRASS and so on which in my opinion is not very straightforward. I will try to discuss these possibilities in the future posts.

Imap function in package iplots

Through my search I found the function imap() from the package "iplots". This is as the author puts: "Note: this function is currently experimental and it may change in thefuture. " It indeed can create an interactive map but the arguments are very limited and I couldnt figure out how can I do the things I want to do (like showing the attributes by clicking on one feature and overlaying results) with this package.
This function relies on Java for run-time which could be an advantage (rich Java environement) and also a disadvantage (needs the package rJava which in turn needs a Java SDK installation on any machine your want to run it).
For now I think I will leave this function to expand my search.

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!.

Interactive maps

I am working on this project (well not yet a project. It's more like a feasibility study...) on developing a program that could be web-based and can draw "interactive maps". By this I mean I want to give the user the ability to see the results of analysis on a map and also be able to interact with them. This interaction would primarily be just getting information about that entity (or it's atrributes) the attributes are coming from table columns that are coming from a manipulation of data.
My primary goal is to do it with open source programs namely R. I am pretty much sure that I can do my analysis (in this case a multiple regression over some variables) and derive the column and results and plot it in R. But I can seem to find a way to be able to create an environment in which the user can interact with the map i.e. interactive maps. This is considered a preliminary task in any GIS software and I have done this with for example ArcGIS from ESRI but doing it with the other tools especially the glorious open sources like R has been unsuccessfull for me so far.
In this blog I will try to summarize whatever I find in the course of my search to find out how I can create interactive maps.