[R] How can I save plot()/points() using SHP files into KML format?

MacQueen, Don macqueen1 at llnl.gov
Wed Mar 14 21:34:46 CET 2012

Since you found readOGR, you might want to look at writeOGR.


Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550

On 2/22/12 3:43 PM, "gztourek" <gztourek at gmail.com> wrote:

>I am new to R and am a very basic user.  I'm importing SHP files, adding
>plots of random locations within my polygon (these files have GPS data),
>then want to save these plots (intact with added points) as KML files to
>look at in GoogleEarth (or possibly as SHP files which I can then convert
>into KML).
>This is as far as I've gotten (code below) and am lost as to next steps,
>Any suggestions or references would be greatly appreciated!  Thanks in
>advance for any help.
># Initialize pseudo random number generator
>  set.seed(700124)
># Read vector representation of the map
>  Kasur <- readOGR("Kasur3.shp", layer = "Kasur3")
># Plot points
>  png("Kasur.png")
>  plot(Kasur)
>  points(spsample(Kasur, n=100, type='random'), col='red', pch=0, cex=0.5)
>  dev.off()
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list