pgirmess (version 1.6.9)

QGIS2sp: Changes a copied-to-clipboard QGIS attribute table into a sp Spatial object or a data.frame

Description

Reads from the clipboard a copy of the QGIS attribute table of a spatial object (points, linestrings, polygons) and convert it into a sp Spatial-class or a data.frame.

Usage

QGIS2sp(df=FALSE)

Arguments

df

If TRUE a data.frame is generated with the coordinates of each shape centroid

Value

A SpatialPointsDataFrame, SpatialLinesDataFrame or SpatialPolygonsDataFrame (df=FALSE) or a data.frame (df=TRUE) with the two first columns corresponding to the centroid coordinates.

See Also

readWKT, read.delim with the argument "clipboard", proj4string, CRS

Examples

Run this code
# NOT RUN {
  if((.Platform$OS.type == "windows") & (interactive())) {
  db <-c("wkt_geom\tname", "POINT(104.55 34.60)\tDENG_LING", "POINT(104.45 34.49)\tDIAO_GOU")
  writeLines(db, "clipboard")
  QGIS2sp() # to write in the console by hand (if copied and paste, one overwrites the clipboard)
  }


# }

Run the code above in your browser using DataCamp Workspace