getgeometry: Get geometry

Description Usage Arguments Value Examples

View source: R/getgeometry.R

Description

Converts a dataframe with a column of characters containing the WKT encoded geometries into an sf object. The column is converted to sfc.

Usage

1
getgeometry(inventory, var)

Arguments

inventory

(data.frame) with a column of characters, which contains the WKT encoded geometries.

var

Name of the character column that holds WKT encoded geometries, as a data/env-variable.

Value

An sf object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(Paracou6_2016)

felttrees <- Paracou6_2016 %>%
dplyr::filter(VernName == "wacapou") %>%
  dplyr::group_by(idTree) %>%
  dplyr::do(LocPts = # inform geometry.
       sf::st_point(c(.$Xutm,.$Yutm)) %>%
       sf::st_as_text()) %>% # as text to easy join with a non spacial table
  tidyr::unnest(LocPts) # here to pass from list to character

inventory <- dplyr::left_join(Paracou6_2016, felttrees, by = "idTree")

Rslt <- getgeometry (inventory, LocPts)

library(ggplot2)
ggplot() +
  geom_sf(data = Rslt)

thomasgaquiere/Maria documentation built on Dec. 24, 2021, 1:20 a.m.