[R-sig-Geo] help with plotKML::kml()

Tomislav Hengl tom.hengl at gmail.com
Mon Aug 7 18:50:23 CEST 2017

I think I set the color of the polygon line "white" which is the KML 
default, so you can only change the color of polygons (fill); see:


To change colors per polygon you should run:

legend = get("colour_scale_factor", envir = plotKML.opts)
kml_layer(eberg_zones, colour=ZONES, colour_scale=legend)

See also: http://gsif.isric.org/doku.php/wiki:tutorial_plotkml

Polygon outlines 
could also be changed but not via plotKML.


On 07-08-17 17:46, MacQueen, Don wrote:
> Hi Tomislav,
> I am using the kml() function in the plotKML package to write a SpatialPolygonsDataFrame object to a kml file, and would like to know if it is possible to specify the fill color and border color separately. I have been looking at documentation and been unable to find a way. I would appreciate any suggestions.
> Suppose "foo" is a SpatialPolygonsDataFrame object with a lat/long coordinate reference system. Then in R I can do, for example,
>    plot(foo, col='yellow', border='red', lwd=2)
> I would like to write a KML file that will display the polygon in Google Earth in a similar manner.
> I have found that
>     plotKML::kml(foo, colour='yellow')
> controls the fill color, but I can't find how to set the border color.
> Ideally, I'd also like to be able specify border only, no fill, and also line widths for the border.
> For example, the kml file might have in it something like:
> <Style id="blue">
>      <PolyStyle>
>      <color>4DFF0000</color>
>      <fill>1</fill>
>      <outline>1</outline>
>      </PolyStyle>
>      <LineStyle>
>      <color>FFFF0000</color>
>      <width>2</width>
>      </LineStyle>
> </Style>
> Thanks
> -Don

More information about the R-sig-Geo mailing list