# NOT RUN {
library(rgdal)
data(eberg_grid)
library(sp)
library(raster)
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
data(SAGA_pal)
data(R_pal)
# }
# NOT RUN {
# Plot two layers one after the other:
kml_open("eberg_grids.kml")
kml_layer(eberg_grid, colour=DEMSRT6, colour_scale=R_pal[["terrain_colors"]])
kml_layer(eberg_grid, colour=TWISRT6, colour_scale=SAGA_pal[[1]])
kml_close("eberg_grids.kml")
# print the result:
library(XML)
xmlRoot(xmlTreeParse("eberg_grids.kml"))[["Document"]]
# }
# NOT RUN {
# examples with sf
eberg_grid_sf <- sf::st_as_sf(eberg_grid)
# sfc objects
# }
# NOT RUN {
kml_open("eberg_grids.kml")
kml_layer(st_geometry(eberg_grid_sf))
kml_close("eberg_grids.kml")
# }
# NOT RUN {
# sf objects
# }
# NOT RUN {
kml_open("eberg_grid_sf.kml")
kml_layer(eberg_grid_sf, colour = DEMSRT6, colour_scale = R_pal[["terrain_colors"]])
kml_layer(eberg_grid_sf, colour = TWISRT6, colour_scale = SAGA_pal[[1]])
kml_close("eberg_grid_sf.kml")
# }
Run the code above in your browser using DataLab