Description Usage Arguments Examples
Generates a kmz from a klm
1 2 |
files_to_zip |
a vector with the files that need to be zipped into the kmz file |
filename |
output file name of the kmz |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## Example using png a locally stored png
# Prepare a dataframe
obj <- data.frame(altitude=1:100,colour=heat.colors(100),heading=1:100,variable=runif(100),longitude=seq(15.202020, 16.202020,length.out=100), latitude=seq(45.459069,46.543523,length.out=100))
coordinates(obj) <- c('longitude','latitude')
proj4string(obj)<- CRS("+init=epsg:4326")
# First generate and save icon
icon(pch=24, col='black',bg='white',filename='icon')
# Generate a legend
gradient_icon(col=colors_legend$colour,
labels = round(c(min(colors_legend$variable_colour),max(colors_legend$variable_colour)),2),
bars=5,
title='title',
tdist=0.2,
tcol='white',
ratio=0.5,
filename='gradient_icon')
# Use function with the generated icon and legend
kml2(obj,altitude='altitude',colour='colour',heading='heading',size='variable_size',icon="icon.png",filename='test.kml',legend_icon='gradient_icon.png')
kml2kmz(files_to_zip=c('icon.png','test.kml','gradient_icon.png'),filename='track_kmz')
#### If you want to change the icon you can store a png in the same folder
#### as where the kml is generated and specify the icon's name (e.g., arrow.png)
#### in the kml function
kml2(obj,altitude='altitude',colour='colour',heading='heading',size='variable',icon="arrow.png",filename='track_kml.kml', legend_icon='gradient_icon.png')
Refer to the icon's name or directory so that the function knows where to find the png
This won't work unless you have a png named 'arrow.png' in the same folder
kml2kmz(files_to_zip=c('arrow.png','track_kml.kml','gradient_icon.png'),filename='track_kmz')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.