Learn R Programming

sf (version 0.1)

sf: create sf object

Description

create sf, which extends data.frame-like objects with a simple feature list column

Usage

sf(df, relation_to_geometry = rep(as.character(NA), ncol(df) - 1))

Arguments

df
object of class data.frame
relation_to_geometry
character vector; indicates for each attribute column how it relates to the geometry; see Details

Details

relation_to_geometry specified for each attribute column how it relates to the geometry, and can have one of following values: "field", "lattice", "entity". "field" is used for attributes that are constant throughout the geometry (e.g. land use), "lattice" where the attribute is an aggregate value over the geometry (e.g. population density), "entity" when the attributes identifies the geometry of particular "thing", such as a building or a city.

Examples

Run this code
pt1 = POINT(c(0,1))
pt2 = POINT(c(1,1))
sfc(list(pt1, pt2))
d = data.frame(a = 1:2)
d$geom = sfc(list(pt1, pt2))
df = sf(d)
d$geom2 = sfc(list(pt1, pt2))
sf(df) # warns

Run the code above in your browser using DataLab