Re: help with plotKML::kml()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: help with plotKML::kml()

Tomislav Hengl-5

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:

https://github.com/cran/plotKML/blob/master/R/layer.SpatialPolygons.R#L112

To change colors per polygon you should run:

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

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

Polygon outlines
(https://developers.google.com/kml/documentation/kmlreference#polystyle)
could also be changed but not via plotKML.

HTH,


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
>

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Loading...