.csv to .shp in r

# Load Library
library(rgdal)
library(sp)

# Load data.
# Download dataset Facebook https://data.humdata.org/organization/facebook.

data  <- read.csv(file.choose())
head(data,3)

# SpatialPointsDataFrame.

class(data) # data.frame
coordinates(data)<-~longitude+latitude # whatever the equivalent is in your 

class(data) # [1] "SpatialPointsDataFrame"...

# EPSG: 4326.

proj4string(data) = CRS("+init=epsg:4326")

# To .shp

writeOGR(data, "/home/willpecc/Escritorio", "facebook_4326", driver = "ESRI Shapefile")

Popular posts from this blog

How to fill gaps in SLC-Off Landsat 7 ETM+ Images with QGIS?