write.grid {mapplots} | R Documentation |
Export a grd object as csv or shapefile
Description
Export a grd object (created by make.grid
) as csv or shapefile.
Usage
write.grid(grd, file, type="csv")
Arguments
grd |
a grid object created by the function |
file |
character string naming the output filename. For csv files do include the extension (e.g. "my_file.csv"); for shapefiles omit the extension (e.g. "my_file"). |
type |
character string specifying the output file type. Must be one of "csv" (default) or "shape" |
Value
A csv file with three columns corresponing to x
, y
and z
(lon, lat, value), or a shapefile with a polygon for each cell in the grd object. The assumed projection is EPSG:4326
Author(s)
Hans Gerritsen
See Also
Examples
library(shapefiles)
data(landings)
data(coast)
byx = 1
byy = 0.5
xlim <- c(-15.5,0)
ylim <- c(50.25,56)
grd <- make.grid(landings$Lon, landings$Lat, landings$LiveWeight, byx, byy, xlim, ylim)
breaks <- breaks.grid(grd,zero=FALSE)
basemap(xlim, ylim, main = "Gadoid landings")
draw.grid(grd,breaks)
draw.shape(coast, col="darkgreen")
legend.grid("topright", breaks=breaks/1000, type=2)
## Not run:
write.grid(grd,"c:/test1.csv")
write.grid(grd,"c:/test1","shape")
## End(Not run)
[Package mapplots version 1.5.2 Index]