I have just recently started using nice and the relatively new library(sf)
. It's nice to see that points and lines can have Z coordinates. For example:
> st_linestring(rbind(c(0,0,0),c(1,1,1)))
LINESTRINGZ(0 0 0, 1 1 1)
However, it seems clear that computations using objects with Z information project it all into the XY plane:
# I wish this returned POINTZ(0.5 0.5 0.5)...
> st_centroid(st_linestring(rbind(c(0,0,0),c(1,1,1))))
POINT(0.5 0.5)
# I wish this returned 1.0...
> st_distance(st_linestring(rbind(c(0,0,0),c(1,1,1))),
st_linestring(rbind(c(2,0,2),c(0,2,2))))
[,1]
[1,] 0
How can I do operations using the Z coordinate without rolling my own?
(I'm guessing that either I'm missing something through lack of understanding, or that the library is so new these operations simply haven't been implemented yet.)