sp_from_wkt: Function to parse a data frame containing WKT strings to a...

View source: R/sp_from_wkt.R

sp_from_wktR Documentation

Function to parse a data frame containing WKT strings to a spatial object.

Description

sp_from_wkt creates geometries from WKT strings and can create spatial data frames from the other variables contained within the input data frame. sp_from_wkt is useful after querying a PostGIS database for geometries in WKT format.

Usage

sp_from_wkt(
  df,
  wkt = "geom",
  data = TRUE,
  keep = FALSE,
  projection = NA,
  verbose = FALSE
)

Arguments

df

Data frame containing a WKT string variable. df can also be a vector of WKT strings.

wkt

Variable name of WKT strings in df. Default is "geom".

data

Should variables other than wkt be added to the spatial object's data-slot? I.e. create a spatial data frame.

keep

Should the wkt be kept in the returned spatial object?

projection

A proj4 string to force the projection system after the WKT strings have been parsed. Default is NA.

verbose

Should the function give messages? Useful when large number of WKT strings are to be parsed. Default is FALSE.

Author(s)

Stuart K. Grange

Examples

## Not run: 
# Make a spatial object from many wkt strings
sp_wkt <- sp_from_wkt(data_wkt, wkt = "geom")

# Make a spatial-data frame object from many wkt strings
sp_wkt_with_data <- sp_from_wkt(data_wkt, wkt = "geom", data = TRUE)


## End(Not run)


skgrange/gissr documentation built on June 20, 2024, 12:02 a.m.