[R-sig-Geo] plotKML - set color according to category

Adam Sparks adamhsparks at gmail.com
Tue Aug 4 07:09:37 CEST 2015

Dear Almut,
I've done this with raster data, but not points as you are describing. If
you convert to a factor and then cut the data, it is possible to create a
KML as you are describing. Towards the end of a script that I put together
for the Manila R User Group there's some code that may help.


On Wed, Jul 29, 2015 at 11:12 PM, Almut Schlaich - Werkgroep Grauwe
Kiekendief <almut.schlaich at grauwekiekendief.nl> wrote:

> Dear Dr. Hengl,
> First of all, I would like to thank you and your colleagues for the great
> package plotKML that I really enjoy using.
> This was indeed a missing link to visualize data, in our case tracking
> data, in Google Earth to easily explore them visually.
> I would like to ask you a question about the possibilities to color the
> points according to a variable.
> In my data table I have a column with classification category "phase"
> (e.g. migration, stopover, breeding, wintering etc.).
> Using e.g.: kml_layer(data,colour=phase,colour_scale=worldgrids_pal[[4]]),
> I get tracks nicely colored depending on category.
> But the difficulty arises when one bird has less levels of the category
> than another (e.g. one bird making no stopover).
> In this case the same colors are used, but for different values of the
> category, just in the order of first appearance.
> To easily compare tracks between individuals I would like to color the
> same category always in the same color. I tried to
> define the colors for each category and give the column with a color value
> per point to the kml_layer function, but this
> didn't work. Is it possible to determine the color of each point?
> At the moment I just use the combination of kml_open, kml_layer and
> kml_close to produce the output.
> Unfortuntely, the much more beautiful and handy plotKML for Space-time
> Trajectory Data Frames doesn't work for the
> tracks since they have too many points. Could you tell me what is the
> limit for this? And might it be possible for more
> points in near future?
> Thank you in advance for your help!
> Kind regards,
> Almut Schlaich
> --
> Almut Schlaich
> Werkgroep Grauwe Kiekendief
> telefoon: +31(0)650459766
> e-mail: almut.schlaich at grauwekiekendief.nl
> postadres: Postbus 46, 9679 ZG Scheemda
> www.grauwekiekendief.nl
> twitter: @grauwekiek
> facebook:
> www.facebook.com/pages/Werkgroep-Grauwe-Kiekendief/190585087622000
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Adam Sparks
Plant Disease Management Specialist
DAPO Box 7777, Metro Manila, Philippines
ph: +63(2) 580-5600 ext 2753

@adamhsparks <https://twitter.com/adamhsparks>

	[[alternative HTML version deleted]]

More information about the R-sig-Geo mailing list