[R-sig-Geo] plotKML: image width and height of legend in KML file
Elbers, Jan
jan.elbers at wur.nl
Wed Apr 15 17:34:12 CEST 2015
Hello,
With my first plotKML project I managed to create a KML file containing a layer with irregular points (air temperature data) and add a legend overlay to it.
I tried changing the size of the legend to no avail, whatever I fill in for "width" and "height" I get a png file that is 120x240 pixels.
What am I doing wrong?
Cheers,
JanE
My code is:
library(sp)
library(plotKML)
library(spacetime)
#
# working directory
setwd('D:/A-user/Hi-Aware/plotKML')
#
# input file
tripfile <- 'wbgt_input_data_new.csv'
tripdata <- read.csv(tripfile)
#
# convert time to POSIX
tripdata$ctime <- as.POSIXct(strptime(tripdata$timestamp,"%Y-%m-%d %H:%M:%S"),format="%Y-%m-%d %H:%M:%S")
#
# lat lon with decimal minutes
tripdata$lat <- tripdata$lat + tripdata$latmin/60.
tripdata$lon <- tripdata$lon + tripdata$lonmin/60.
#
# create STIDF object
sp <- SpatialPoints(tripdata[,c("lon","lat")])
proj4string(sp) <- CRS("+proj=longlat +datum=WGS84")
tripdata.st <- STIDF(sp, time = tripdata$ctime, data = tripdata[,c("t2m","rh")])
#
# save to kml with legend bar overlay
kml_open(file.name = paste(tripfile, ".kml", sep=""))
kml_layer(tripdata.st, file.name=paste(tripfile, ".kml", sep=""), colour=t2m, labels="", points_names="",
shape="http://maps.google.com/mapfiles/kml/pal2/icon18.png", kmz=FALSE, open.kml=TRUE)
kml_legend.bar(x=tripdata$t2m, width=100, height=500, pointsize = 10, legend.file="legend.png",
legend.pal=SAGA_pal$SG_COLORS_DEFAULT, z.lim = range(tripdata$t2m, na.rm=TRUE, finite=TRUE))
kml_screen(image.file = "legend.png", position = "ML", sname = "legend")
kml_close(file.name = paste(tripfile, ".kml", sep=""))
end of code
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list