write.grid | R Documentation |
Export a grd object (created by make.grid
) as csv or shapefile.
write.grid(grd, file, type="csv")
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" |
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
Hans Gerritsen
make.grid
, write.shapefile
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.