Dear Marta,
I am not sure what is the projection system you use for the Algarve case study? If it is different
from CRS("+proj=longlat +datum=WGS84"), then you do need to first reproject your maps.
You should really look at the examples from the book by Bivand et al.:
http://www.asdar-book.org/code.php?chapter=3&figure=1
http://www.asdar-book.org/code.php?chapter=3&figure=2
Here you will find small examples of how to export any raster map to GE (it reprojects a map using
the MapResample method of ILWIS GIS):
http://geomorphometry.org/R.asp
I personally do not use much the maptools to generate GE KMLs, but instead write directly a KML file
from R e.g. to export a time-series of interpolated temperature images to KML in a loop:
I guess you need to read the KML tutorial
(http://code.google.com/apis/kml/documentation/kml_tut.html) to find out what exactly you need to
use.
hth
Tom Hengl
http://spatial-analyst.net
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of
Marta Rufino
Sent: Friday, October 24, 2008 11:50 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] bad position of png & klm file in google earth
Dear list,
I would like to start by acknowledging the wonderful work of this
support list :-)
I have a question, which should be prety dummy,... but I was looking
around in the net, in reports, etc. and could not sort it out.
I am trying to export a image plot to google earth. I manage to do it
with points data... ok. but when I do it with the images, they simply
go to Fiji (which I am sure it is a nice place... but a bit far from the
Algarve, where it should be).
Even the example given in the help file, the image goes to the same
place. What am I doing wrong?
require(maptools); require(rgdal)
# This is the example, in the file
opt_exask <- options(example.ask=FALSE)
qk <- SpatialPointsDataFrame(quakes[, c(2:1)], quakes)
proj4string(qk) <- CRS("+proj=longlat")
tf <- tempfile()
SGqk <- GE_SpatialGrid(qk)
png(file=paste(tf, ".png", sep=""), width=SGqk$width,
height=SGqk$height, bg="transparent")
par(mar=c(0,0,0,0), xaxs="i", yaxs="i")
plot(qk, xlim=SGqk$xlim, ylim=SGqk$ylim, setParUsrBB=TRUE)
dev.off()
kmlOverlay(SGqk, paste(tf, ".kml", sep=""), paste(tf, ".png", sep=""))
# than the files produced are in
tf()
I go to the file, pick it the two of them and drag it in google earth...
and there they are, in Fiji!!! I am sure it is silly, but it is my first
steps in googleearth--R :-(
If I open it through google earth, it is the same...
A second doubt I have is if we can set apriori, in R the markers
projected in google earth... how do I do if instead of the pins, I want
a ball? Do I have to change one by one?
Thank you very much in advance,
Best wishes,
Marta
I am in windows, R 2.7.1, maptools, version 0.7-15, 2008-08-14...
GDAL 1.5.2, released 2008/05/29
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo