

In the code chunk above I created multiple sfg points, inputted each into the st_sfc() function to create a single sfc object to store all the point data. # Bounding box: xmin: 1 ymin: 2 xmax: 5 ymax: 4 #create five sfg point objects point1 <- st_point( x = c( 1, 3)) point2 <- st_point( x = c( 2, 4)) point3 <- st_point( x = c( 3, 3)) point4 <- st_point( x = c( 4, 3)) point5 <- st_point( x = c( 5, 2)) points <- st_sfc(point1,point2,point3,point4,point5) # create a single sfc points object points # Geometry set for 5 features An sfc object can store any number of sfg objects, as well as information on the coordinate reference system. What if we wanted to create an sfg object with more than one point? To do so we will need to use another function to build on the sfg object and create what’s called a simple feature geometry column object ( sfc) using the st_sfc() function. Furthermore st_point() can only store a single point object. An sfg object is a spatial object that only stores XY coordinate information and does not have any information on the geographic coordinate system, datum or projection those coordinates are in, nor does it have any other attribute data associated with that point.

The st_point() function outputs a simple feature geometry ( sfg) object with geometry type POINT. The R vector c(1,3) specifies a point whose x coordinate is 1 and and the y coordinate is 3. The function takes a single R vector as its argument with two numeric data elements corresponding to the X and Y coordinate. In the code chunk above I create a spatial object called a_single_point using a function st_point() from the sf package. A polygon is 2-dimensional as you can measure both its length and its area.Īttributes(a_single_point) #view the different components of an sfg object # $class.Lines are 1-dimensional in that they one can measure its length, but cannot measure its area.Points are 0-dimensional in that they have no measurable length or area.A polygon feature consists of at least three XY coordinates that are fully enclosed (Figure 3.1C). A line feature consists of two connected vertices whose location is defined by a single XY coordinate (Figure 3.1B). The simplest geometry for a spatial object is a point, where each feature has a single XY coordinate (Figure 3.1A). Here spatial geometry refers the idea that each feature has a shape that can be described by at least one two-dimensional (x,y) coordinate that references a specific location on earth.

There are 14 additional types of geometry that can be represented in sf which for now we can ignore but are detailed in the sf vignette.Īs mentioned in the previous chapter, vector data are used to represent an object (or feature) that occurs somewhere on Earth that has some kind of spatial geometry. In this tutorial we will focus on three simple types of geometry: points, linestrings (i.e. lines) and polygons. The sf package can be used to represent different geometry types in R.
