write.grid: Export a grd object as csv or shapefile

write.gridR 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 make.grid.

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

make.grid, write.shapefile .

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)

mapplots documentation built on Aug. 25, 2023, 5:15 p.m.