I have five longitude and latitude that form a shape like this.
df <- c(order=1:5,
lon=c(119.4,119.4,119.4,119.5,119.5),
lat=c(-5.192,-5.
library(sfheaders)
on CRAN from 20191004 can take a data.frame and convert it to sf
objects
library(sf)
library(sfheaders)
df <- data.frame(
lon = c(119.4, 119.4, 119.4, 119.5, 119.5),
lat = c(-5.192, -5.192, -5.187, -5.187, -5.191)
)
sfheaders::sf_polygon(
obj = df
)
## given only two columns of data are in df there's no need to specify lon & lat arguments
# Simple feature collection with 1 feature and 1 field
# geometry type: POLYGON
# dimension: XY
# bbox: xmin: 119.4 ymin: -5.192 xmax: 119.5 ymax: -5.187
# epsg (SRID): NA
# proj4string:
# id geometry
# 1 1 POLYGON ((119.4 -5.192, 119...