Thanks Pierre, that sure helps. But the problem with using this sp package
is that I need to overlay the plot with the map of the world. I am not sure
how to do it so that everything lies in perfect alignment; I tried using the
map command as

map("world", projection="mollweide", plot="n")
spplot(data, zcol='z', col.regions=rainbow(64), add=TRUE)
map("world", projection="mollweide",add=TRUE)

But then things are not as expected, the co-ordinates don't match up :(
Any help from anyone will be highly appreciated.
Thanks.

-Aritra

On Wed, Apr 27, 2011 at 12:17 AM, Pierre Roudier
<pierre.roudier@gmail.com>wrote:

> Hi,
>
> It is not clear to me why you do not make use of the sp package. It is
> not clear what projection your data is in, I assume it is geographic
> coordinates/WGS84. Let's say you have your data in a data.frame called
> df, with columns lat, lon and z:
>
> set.seed(0)
> npts <- 100
> lon <- runif(n=npts, min=-180, max=180)
> lat <- runif(n=npts, min=-90, max=90)
> z <- rnorm(n=npts, mean=10, sd=5)
> df <- data.frame(lon, lat, z)
>
> library(sp)
> coordinates(df) <- ~lon+lat
>
> # you can plot it already:
> spplot(df, zcol='z')
>
> # let's add some information about the data projection:
> proj4string(df) <- CRS("+init=epsg:4326")
>
> # if you want to use the Mollveide projection, we have to change
> projection:
> library(rgdal)
> df.proj <- spTransform(df, CRS("+proj=moll +lon_0=0 +x_0=0 +y_0=0
> +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
>
> # Plot it again
> spplot(df.proj, zcol='z')
>
> # change the color scheme
> spplot(df.proj, zcol='z', col.regions=rainbow(64))
>
> Hope this help,
>
> Pierre
>
> 2011/4/27 sourav sengupta <aritra.sourav@gmail.com>:
> > Hello everyone,
> >
> > I have a big data set with latitude, laongitude and the values (Z). I
> want
> > to plot the data on a map using a color scheme, so that the color at a
> > particular lat-long value depends on the Z-value.
> >
> > First I used a projection to get the x-y coordinates. Then defined a
> color
> > scheme, and made a scatter plot.
> >
> > rescale(as.numeric((data$z))) -> z
> > coords <- mapproject(data$lon, data$lat, projection="mollweide",
> > parameters=NULL, orientation=NULL)
> > plot(coords$x, coords$y,col=gray(seq(0,10,,11)/10)[abs(10*(1-z))])
> > map("world", projection="",add=TRUE)
> >
> > This is creating the plot for me, but the quality is very bad. I am not
> able
> > to make it look really smooth. I even used pch="." but that made it very
> > grainy. Can anyone help me in this regard? Thanks.
> >
> > -Aritra
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>
>
> --
> Scientist
> Landcare Research, New Zealand
>

	[[alternative HTML version deleted]]

