Skip to content

Commit

Permalink
Merge branch 'main' of github.com:r-spatial/sf
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Jan 10, 2025
2 parents cb2c3bf + 4adc3df commit 8616ff9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions vignettes/sf7.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ coordinates, meaning that they are associated to points on a flat
space, or to unprojected or _geographic_ coordinates, when they
refer to angles (latitude, longitude) pointing to locations on a
sphere (or ellipsoid). The flat space is also referred to as $R^2$,
the sphere as $S^2$
the sphere as $S^2$.

Package `sf` implements _simple features_, a standard for point,
line, and polygon geometries where geometries are built from points
Expand All @@ -68,8 +68,8 @@ to $R^2$, the two-dimensional flat space.

Yet, more and more data are routinely served or exchanged using
geographic coordinates. Using software that assumes an $R^2$, flat
space may work for some problems, and although `sf` up to version 0.9-x
had some functions in place for spherical/ellipsoidal computations
space may work for some problems, and although `sf`
has some functions in place for spherical/ellipsoidal computations
(from package `lwgeom`, for computing area,
length, distance, and for segmentizing), it has also happily warned
the user that it is doing $R^2$, flat computations with such coordinates with messages like
Expand Down Expand Up @@ -252,6 +252,12 @@ sf_use_s2(TRUE)

# Measures

This section compares the differences in results between the `s2`
and `lwgeom` (`sf_use_s2(FALSE)`) packages for calculating area,
length and distance using geographic coordinates. Note that engaging
the `GEOS` engine would require reprojection of the vector layer
to the planar coordinate system (e.g. `EPGS:3857`).

## Area
```{r eval=require("lwgeom", quietly = TRUE)}
options(s2_oriented = FALSE) # correct orientation from here on
Expand All @@ -276,10 +282,9 @@ sf_use_s2(FALSE)
l2 = st_length(nc_ls)
plot(l1 , l2)
abline(0, 1)
summary((l1-l2)/l1)
summary((l1 - l2)/l1)
```


## Distances
```{r}
sf_use_s2(TRUE)
Expand All @@ -288,7 +293,7 @@ sf_use_s2(FALSE)
d2 = st_distance(nc, nc[1:10,])
plot(as.vector(d1), as.vector(d2))
abline(0, 1)
summary(as.vector(d1)-as.vector(d2))
summary(as.vector(d1) - as.vector(d2))
```

# Predicates
Expand Down

0 comments on commit 8616ff9

Please sign in to comment.