Created
October 9, 2014 19:56
Revisions
-
anarosner created this gist
Oct 9, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #code snippet to import/export spatial files to/from r library(maptools) library(rgdal) # go to http://spatialreference.org/ to find proj4 string if you don't have it #for importing/exporting esri shapefiles r_object <- readShapePoly( fn="shapefile_name", proj4string=CRS("sdfsdlfj") ) r_object$new_col <- r_object$old_col*10 writeOGR(r_object, ".", layer="new_shapefile_name", driver="ESRI Shapefile") #for exporting geojsons (from imported esri shapefile) #example for Chris boo <- readShapePoly( fn="huc4", IDvar="HUC4", proj4string=CRS("sdfsdlfj") ) #(fn is short for filename, not function) writeOGR(boo, "huc.geojson", layer="huc", driver="GeoJSON")