Hi Robert:

Thank you for the answer.

Here is a link to the file...  http://bit.ly/15xryk1

The file have several layers...   I think the issue is that x and y are not
regularly spaced.
I tried to do this, following your suggestion with the rasterFromXYZ
function:

l<-list(x,y,z)  # referring to x,y,z from the initial code
varMatrix<-do.call(rbind,l)
varRaster2 <- rasterFromXYZ(varMatrix)

And got this message...
Error in rasterFromXYZ(varMatrix) : x cell sizes are not regular

#Using the variable "varRaster" from the initial code

res(varRaster)
[1] 0.2603037 0.2916659

Gives the not regular spaced data set...

If I add "useRaster=TRUE" to the 'image' function I get similar error
regarding non-regular grid...

Guillermo


On Mon, Oct 14, 2013 at 10:08 PM, Robert J. Hijmans <r.hijmans@gmail.com>wrote:

> It seems that the files has other variables than lon & lat that are
> used. It looks like a projection is used, but then again, the axes
> range suggests lon/lat. Can you show more info about the file contents
> (e.g.  print(varRaster) ) or str(ex.nc).
> Even better if you can make the file available to me. In principle you
> can of course make a RasterLayer from your x, y and z, particularly if
> x and y are regularly spaced.
> Robert
>
> On Mon, Oct 14, 2013 at 11:04 AM, Guillermo E. Ponce-Campos
> <geponce@gmail.com> wrote:
> > Hello:
> >
> > I have been trying to plot a netcdf layer as a raster and have found one
> > single issue that I'd like know if I'm doing something wrong.  If I use
> the
> > function "image" from raster package there's no problem at all, the thing
> > is that I would like to handle this layer as a raster and be able to map
> it
> > correctly or save it as a geotif.
> >
> > This is an example using both approaches to map the netcdf layer: as a
> > raster and using "image(x,y,z...).
> >
> > library(ncdf)
> >
> > library(maptools)
> >
> > library(raster)
> >
> > varRaster<-raster("SMOS_File.nc", varname="Soil_Moisture")
> >
> > plot(varRaster)
> > data(wrld_simpl)
> > plot(wrld_simpl, add = TRUE)
> >
> > # Resulting plot (some offset is occurring by opening the layer as a
> raster
> >  --> http://bit.ly/19IFfA2
> >
> >
> > #Using "image" there's no problem...
> >
> > ex.nc = open.ncdf("SMOS_File.nc")
> >
> > print(ex.nc)
> > summary(ex.nc)
> > y = get.var.ncdf( ex.nc, "lat")
> > x = get.var.ncdf( ex.nc, "lon")
> > z = get.var.ncdf( ex.nc, "Soil_Moisture")
> >
> > image(x,y,z, zlim=c(-0.9,1), col = heat.colors(37))
> > plot(wrld_simpl, add = TRUE)
> >
> > # Resulting plot --> http://bit.ly/1cJ0vXo
> >
> > Is there anyway to handle the netcdf layer as a raster and be able to map
> > it correctly.  I already tried to write the raster as a geotif and open
> it
> > in other software such as GRASS or ArcMap and is still showing up with
> the
> > offset.
> >
> >
> > Thanks for any help with this.
> > Guillermo
> >
> > --
> > *Guillermo E. Ponce-Campos*
> > *PGP Key ID*: 0x57EDC060
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
*Guillermo E. Ponce-Campos*
*PGP Key ID*: 0x57EDC060
*Ph*. (520) 261-8486

	[[alternative HTML version deleted]]

