[R] Convert poly line to polygon in R

MacQueen, Don macqueen1 at llnl.gov
Thu Nov 16 23:12:41 CET 2017


In addition to which, the
  rgeos
package may have something.

If it's just a single polyline, it may be pretty easy to pull out the coordinates as a two column matrix, append the first row at the end, and rebuild it as a polygon.

The readOGR function in the rgdal package is probably a better choice for loading a shapfile into R. See also the relatively new package named "sf".

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 11/13/17, 12:47 AM, "R-help on behalf of Jeff Newmiller" <r-help-bounces at r-project.org on behalf of jdnewmil at dcn.davis.ca.us> wrote:

    Might want to post this on R-sig-geo.
    
    Might also want to post in plain text format... see below how your message got messed up coming through the mailing list.
    -- 
    Sent from my phone. Please excuse my brevity.
    
    On November 12, 2017 9:58:56 PM PST, Javad Bayat via R-help <r-help at r-project.org> wrote:
    >I have a shape file as poly line and I want to convert it to polygon.Is
    >it possible to do that in R?lake
    ><-readShapeLines("./lake_main_utm.shp")proj4string(lake) <-
    >CRS("+proj=utm +zone=39 +datum=WGS84")
    >
    >Sincerely.
    >
    >	[[alternative HTML version deleted]]
    >
    >______________________________________________
    >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
    >https://stat.ethz.ch/mailman/listinfo/r-help
    >PLEASE do read the posting guide
    >http://www.R-project.org/posting-guide.html
    >and provide commented, minimal, self-contained, reproducible code.
    
    ______________________________________________
    R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
    



More information about the R-help mailing list