[R-sig-Geo] add a field to sf object and point shape in kml

Vijay Lulla v|j@y|u||@ @end|ng |rom gm@||@com
Tue May 7 19:11:18 CEST 2019


Good one Barry!  As far as I'm aware sf uses rgdal to write various file
formats and writeOGR has options called dataset_options and layer_options
which are considered experimental.  Do you know if either of these options
can be used instead of creating a new field/attribute for the sf
dataframe?  More importantly, I would like to know your opinion of using
these options vs creating an attribute.
Thanks in advance,
Vijay.

On Tue, May 7, 2019 at 11:07 AM Barry Rowlingson <b.rowlingson using gmail.com>
wrote:

> On Tue, May 7, 2019 at 12:54 PM Marta Rufino <marta.m.rufino using gmail.com>
> wrote:
>
> > Hi,
> >
> > Two very simple question:
> >
> > 2)
> > Can we change the polygon col/fill and point shape/col when exporting sf
> > obejcts to kml, using the function:
> > st_write(sf.object, " sf.object  .kml", driver='kml')
> >
> >
> Setting styles for writing KML using GDAL/OGR is described here:
>
>
> https://gis.stackexchange.com/questions/297494/how-to-style-kml-through-libkml-layer-creation-options
>
> For example I have an sf data frame of Osprey tracking data (as points),
> and if I create a new field:
>
>
> osp$OGR_STYLE="PEN(c:#128020,w:5px)"
>
> and then:
>
> st_write(osp, "/tmp/osp.kml",driver="libkml")
>
> then the features in the KML get written with:
>
>          <LineStyle>
>             <color>ff208012</color>
>             <width>5</width>
>           </LineStyle>
>
> I realise now that "PEN" is probably wrong for point features, but it
> should all be explained in the google OGR style docs:
>
> https://www.gdal.org/ogr_feature_style.html
>
> and in the links in that GIS stack exchange question...
>
> Barry
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list