Richard,

It would appear that your raster is already longitude/latitude. However,
 this bit "+proj=lonlat" causes the error, plase use

projection(r.tmp) <- "+proj=longlat +datum=WGS84"

and it should work

In other cases, you could have used "projectRaster"

Robert

On Wed, Feb 1, 2012 at 5:03 PM, Richard Ma <xuanlong.ma@uts.edu.au> wrote:

> Hi all,
>
> Below is the information of my raster file:
>
> > r.tmp
> class       : RasterLayer
> dimensions  : 220, 200, 44000  (nrow, ncol, ncell)
> resolution  : 0.05, 0.05  (x, y)
> extent      : 128, 138, -23, -12  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=lonlat +datum=WGS84 +no_defs +ellps=WGS84
> +towgs84=0,0,0
> values      : in memory
> min value   : 5.079816e-05
> max value   : 0.9999755
>
> however, when I want to use KML function (raster package) to export this
> raster to KML, I got an error.
>
> > KML(r.tmp, file = 'r_tmp.kml')
> Error in .local(x, ...) : CRS of x must be longitude / latitude
>
> Does this means I need to reproject my raster file to longitude/latitude
> coordinates system? How to do that?
>
>
> -----
> Richard Ma
> PhD student, Ecology & Remote Sensing
> Climate Change Cluster, Department of Environment Science
> University of Technology, Sydney
> http://everydropr.wordpress.com
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/Problem-when-export-raster-to-KML-tp7245302p7245302.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

