[R-sig-Geo] add a field to sf object and point shape in kml
b@row||ng@on @end|ng |rom gm@||@com
Tue May 7 21:23:05 CEST 2019
On Tue, May 7, 2019 at 6:11 PM Vijay Lulla <vijaylulla using gmail.com> wrote:
> 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.
Not quite - `sf` uses the underlying C/C++ GDAL/OGR library directly. The
`rgdal` package does the same. One doesn't use the other.
To write KML the GDAL/OGR library uses either its "kml" or its "libkml"
driver which is documented here:
dataset_options and layer_options tend to be single value options per
dataset and per layer - to set something per *feature* is going to need a
lot more information, and having an extra attribute in the feature table
(spatial data frame) seems reasonable.
I've not quite understood all the libkml creation options relating to
styles so there may be an easy way to do it but I don't think the overhead
of an extra column is too much trouble.
> 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,
> On Tue, May 7, 2019 at 11:07 AM Barry Rowlingson <b.rowlingson using gmail.com>
>> On Tue, May 7, 2019 at 12:54 PM Marta Rufino <marta.m.rufino using gmail.com>
>> > 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:
>> For example I have an sf data frame of Osprey tracking data (as points),
>> and if I create a new field:
>> and then:
>> st_write(osp, "/tmp/osp.kml",driver="libkml")
>> then the features in the KML get written with:
>> I realise now that "PEN" is probably wrong for point features, but it
>> should all be explained in the google OGR style docs:
>> and in the links in that GIS stack exchange question...
>> [[alternative HTML version deleted]]
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
[[alternative HTML version deleted]]
More information about the R-sig-Geo