4

The following picture describes a simple feature collection of the package sf in R. However, I don't get the meaning of sfc. A feature collections consists of a set of simple features, three in the picture.

Each simple feature has a geometry, sfg, granted, but what is the role of sfc?

Why does is span multiple features?

In my understanding, a simple feature should consists of exactly one sfc, and each sfc of a set of geometries (sfg).

Can someone help me to understand the relationship between a simple feature (one row) and the geometry list-column (sfc)?

enter image description here

7

I have found it the easiest to think of sfc as sf without any data - just the plain geometry.

The hierarchy the three object types in the sf universe:

  • sfg is the lowest unit; it has only coordinates (according to the well-known text standard)
  • sfc is a set of sfg's, plus - crucially! - information about interpretation of the coordinate reference system / are the coordinates in meters, or degrees? plane or sphere? if sphere, which one? this is highly standardized stuff, often described in terms of EPSG codes
  • sf is a sfc geometry with data columns, in addition to the geometry

And because example is more than 1000 words, consider this code:

library(sf)

shape <- st_read(system.file("shape/nc.shp", package="sf")) # included with sf package

class(shape)
shape # data + geometry

geometry <- st_geometry(shape) # pull sfc from sf

class(geometry)
geometry # no data, but geometry is present

ashe <- geometry[[1]] # pull sfg from sfc

class(ashe)
ashe # a polygon, but without CRS - no way to interpret the coordinates without external information

You will see information disappearing as you go from complex to simple objects.

2
  • So, just to be clear, all features/rows of an sf-object (green box) share the same sfc-object (red box)? In orther words, n features, 1 sfc consisting of n geometries?
    – Funkwecker
    Oct 20 at 10:32
  • A sfc consists of a set of sfg's + infomation on how to interpret the numbers in the coordinates (coordinate reference system). So yes, n individual geometries in a sfc with n rows + 1 CRS definition Oct 20 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.