[R-sig-Geo] How to write R dataframe to shapefile

Dan Putler dan.putler at sauder.ubc.ca
Sun Dec 20 19:30:25 CET 2009


Hi Mark,

The easy way is a two step process, using the sp and rgdal packages.
Create a SpatialPointsDataFrame using the SpatialPointsDataFrame
function in sp, and then write it out using the writeOGR function in
rgdal. You can get things correct coordinate system by using
CRS("+init=epsg:4979") for the proj4string argument to
SpatialPointsDataFrame, although there are a number of other EPSG codes
that corresponds to WGS84 geographic coordinates.

Dan

On Sun, 2009-12-20 at 11:21 -0600, Mark Na wrote:
> Hello,
> 
> I have an R dataframe with four columns (lat, long, date and time); these
> data were imported from a .gpx and then manipulated. Now, I'd like to write
> these data to a shapefile, using lat and long to specify the spatial
> coordinates and specifying WGS 84 for the geographic coordinate system.
> 
> I'd appreciate any pointers, thank you.
> 
> Mark Na
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- 
Dan Putler
Sauder School of Business
University of British Columbia



More information about the R-sig-Geo mailing list