read_geometry {ncdfgeom} | R Documentation |
Read NetCDF-CF spatial geometries
Description
Attempts to convert a NetCDF-CF DSG Simple Geometry file into a sf data.frame.
Usage
read_geometry(nc_file)
Arguments
nc_file |
character file path to the nc file to be read. |
Value
sf data.frame
containing spatial geometry of type found in the NetCDF-CF DSG file.
References
http://cfconventions.org/index.html
Examples
huc_eta_nc <- tempfile()
file.copy(system.file('extdata','example_huc_eta.nc', package = 'ncdfgeom'),
huc_eta_nc, overwrite = TRUE)
vars <- ncmeta::nc_vars(huc_eta_nc)
hucPolygons <- sf::read_sf(system.file('extdata','example_huc_eta.json', package = 'ncdfgeom'))
plot(sf::st_geometry(hucPolygons))
names(hucPolygons)
hucPolygons_nc <- ncdfgeom::write_geometry(nc_file=huc_eta_nc,
geom_data = hucPolygons,
instance_dim_name = "station",
variables = vars$name)
huc_poly <- read_geometry(huc_eta_nc)
plot(sf::st_geometry(huc_poly))
names(huc_poly)
[Package ncdfgeom version 1.1.6 Index]