Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

DF2SpatialPointsDataFrame

change data.frame to SpatialPointsDataFrame


Description

This function modifies an object of class data.frame to one of class SpatialPointsDataFrame

Usage

DF2SpatialPointsDataFrame(x, coords = c("x", "y"), 


    crs = sp::CRS("+init=epsg:28992"))

Arguments

x

data frame to be converted

coords

which columns are coordinates

crs

projection scheme

Value

the new object of class SpatialPointsDataFrame

Author(s)

Markus Loecher

Examples

if (requireNamespace("sp", quietly = TRUE)) {


  data("meuse", package = "sp", envir = environment())


  meuseSP = DF2SpatialPointsDataFrame(meuse)


  


  sp::plot(meuseSP, asp = 1, cex = 4 * meuse$zinc/max(meuse$zinc),


       pch = 1, col = as.numeric(meuse$ffreq)+1 )


  data("meuse.riv", package = "sp", envir = environment())


  lines(meuse.riv)  


} else {


  print("package sp must be installed for this example")


}

RgoogleMaps

Overlays on Static Maps

v1.4.5.3
GPL
Authors
Markus Loecher
Initial release
2020-02-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.