Creates a file with point, line or polygon instance data ready for the extended NetCDF-CF timeSeries featuretype format.

Will also add attributes if provided data has them.

write_geometry(
  nc_file,
  geom_data,
  instance_dim_name = NULL,
  variables = list()
)

Arguments

nc_file

character file path to the nc file to be created.

geom_data

sf data.frame with POINT, LINESTRING, MULTILINESTRING, POLYGON, or MULTIPOLYGON geometries. Note that three dimensional geometries are not supported. sp geometries will be coerced to sf with sf::as_Spatial.

instance_dim_name

character Not required if adding geometry to a NetCDF-CF Discrete Sampling Geometries timeSeries file. For a new file, will use package default -- "instance" -- if not supplied.

variables

character If a an existing netCDF files is provided, this list of variables that should be related to the geometries.

References

  1. http://cfconventions.org/cf-conventions/cf-conventions.html

Examples

write_geometry,Write geometries and attributes to NetCDF-CF,Write geometries and attributes to NetCDF-CF — write_geometry,Source: R/write_geometry.R,write_geometry.Rd,character(0),write_geometry,character(0),list(title = "Description", contents = "

Creates a file with point, line or polygon instance data ready for the \nextended NetCDF-CF timeSeries featuretype format.

\n

Will also add attributes if provided data has them.

"),list(description = "Creates a file with point, line or polygon instance data ready for the \nextended NetCDF-CF timeSeries featuretype format.\nWill also add attributes if provided data has them."),write_geometry( nc_file, geom_data, instance_dim_name = NULL, variables = list() ),list(list(name = "nc_file", description = "

character file path to the nc file to be created.

"), list(name = "geom_data", description = "

sf data.frame with POINT, LINESTRING, MULTILINESTRING, \nPOLYGON, or MULTIPOLYGON geometries. Note that three dimensional geometries \nare not supported. sp geometries will be coerced to sf with sf::as_Spatial.

"), list(name = "instance_dim_name", description = "

character Not required if adding geometry to a \nNetCDF-CF Discrete Sampling Geometries timeSeries file. For a new file, will \nuse package default -- \"instance\" -- if not supplied.

"), list(name = "variables", description = "

character If a an existing netCDF files is provided, this \nlist of variables that should be related to the geometries.

")),TRUE,
hucPolygons <- sf::read_sf(system.file('extdata','example_huc_eta.json', package = 'ncdfgeom')) hucPolygons_nc <- ncdfgeom::write_geometry(nc_file=tempfile(), geom_data = hucPolygons) try({ ncdump <- system(paste("ncdump -h", hucPolygons_nc), intern = TRUE) cat(ncdump ,sep = "\n") }, silent = TRUE)
#> netcdf file1051847c05f8e { #> dimensions: #> instance = 2 ; #> char = 38 ; #> node = 2628 ; #> variables: #> char TNMID(instance, char) ; #> TNMID:units = "unknown" ; #> TNMID:grid_mapping = "grid_mapping" ; #> TNMID:geometry = "geometry_container" ; #> char METASOURCE(instance, char) ; #> METASOURCE:units = "unknown" ; #> METASOURCE:grid_mapping = "grid_mapping" ; #> METASOURCE:geometry = "geometry_container" ; #> char SOURCEDATA(instance, char) ; #> SOURCEDATA:units = "unknown" ; #> SOURCEDATA:grid_mapping = "grid_mapping" ; #> SOURCEDATA:geometry = "geometry_container" ; #> char SOURCEORIG(instance, char) ; #> SOURCEORIG:units = "unknown" ; #> SOURCEORIG:grid_mapping = "grid_mapping" ; #> SOURCEORIG:geometry = "geometry_container" ; #> char SOURCEFEAT(instance, char) ; #> SOURCEFEAT:units = "unknown" ; #> SOURCEFEAT:grid_mapping = "grid_mapping" ; #> SOURCEFEAT:geometry = "geometry_container" ; #> char LOADDATE(instance, char) ; #> LOADDATE:units = "unknown" ; #> LOADDATE:grid_mapping = "grid_mapping" ; #> LOADDATE:geometry = "geometry_container" ; #> char GNIS_ID(instance, char) ; #> GNIS_ID:units = "unknown" ; #> GNIS_ID:grid_mapping = "grid_mapping" ; #> GNIS_ID:geometry = "geometry_container" ; #> double AREAACRES(instance) ; #> AREAACRES:units = "unknown" ; #> AREAACRES:missing_value = -9999.999 ; #> AREAACRES:grid_mapping = "grid_mapping" ; #> AREAACRES:geometry = "geometry_container" ; #> double AREASQKM(instance) ; #> AREASQKM:units = "unknown" ; #> AREASQKM:missing_value = -9999.999 ; #> AREASQKM:grid_mapping = "grid_mapping" ; #> AREASQKM:geometry = "geometry_container" ; #> char STATES(instance, char) ; #> STATES:units = "unknown" ; #> STATES:grid_mapping = "grid_mapping" ; #> STATES:geometry = "geometry_container" ; #> char HUC12(instance, char) ; #> HUC12:units = "unknown" ; #> HUC12:grid_mapping = "grid_mapping" ; #> HUC12:geometry = "geometry_container" ; #> char NAME(instance, char) ; #> NAME:units = "unknown" ; #> NAME:grid_mapping = "grid_mapping" ; #> NAME:geometry = "geometry_container" ; #> char HUTYPE(instance, char) ; #> HUTYPE:units = "unknown" ; #> HUTYPE:grid_mapping = "grid_mapping" ; #> HUTYPE:geometry = "geometry_container" ; #> char HUMOD(instance, char) ; #> HUMOD:units = "unknown" ; #> HUMOD:grid_mapping = "grid_mapping" ; #> HUMOD:geometry = "geometry_container" ; #> char TOHUC(instance, char) ; #> TOHUC:units = "unknown" ; #> TOHUC:grid_mapping = "grid_mapping" ; #> TOHUC:geometry = "geometry_container" ; #> double NONCONTRIB(instance) ; #> NONCONTRIB:units = "unknown" ; #> NONCONTRIB:missing_value = -9999.999 ; #> NONCONTRIB:grid_mapping = "grid_mapping" ; #> NONCONTRIB:geometry = "geometry_container" ; #> double NONCONTR_1(instance) ; #> NONCONTR_1:units = "unknown" ; #> NONCONTR_1:missing_value = -9999.999 ; #> NONCONTR_1:grid_mapping = "grid_mapping" ; #> NONCONTR_1:geometry = "geometry_container" ; #> double SHAPE_Leng(instance) ; #> SHAPE_Leng:units = "unknown" ; #> SHAPE_Leng:missing_value = -9999.999 ; #> SHAPE_Leng:grid_mapping = "grid_mapping" ; #> SHAPE_Leng:geometry = "geometry_container" ; #> double SHAPE_Area(instance) ; #> SHAPE_Area:units = "unknown" ; #> SHAPE_Area:missing_value = -9999.999 ; #> SHAPE_Area:grid_mapping = "grid_mapping" ; #> SHAPE_Area:geometry = "geometry_container" ; #> double x_nodes(node) ; #> x_nodes:units = "degrees_east" ; #> x_nodes:axis = "X" ; #> double y_nodes(node) ; #> y_nodes:units = "degrees_north" ; #> y_nodes:axis = "Y" ; #> int geometry_container ; #> geometry_container:node_coordinates = "x_nodes y_nodes" ; #> geometry_container:geometry_type = "polygon" ; #> geometry_container:node_count = "node_count" ; #> geometry_container:grid_mapping = "grid_mapping" ; #> int node_count(instance) ; #> node_count:long_name = "count of coordinates in each instance geometry" ; #> int grid_mapping ; #> grid_mapping:grid_mapping_name = "latitude_longitude" ; #> grid_mapping:semi_major_axis = 6378137. ; #> grid_mapping:inverse_flattening = 298.257223563 ; #> grid_mapping:longitude_of_prime_meridian = 0. ; #> #> // global attributes: #> :Conventions = "CF-1.8" ; #> }
,list(list(title = "References", contents = "\n
    \n
  1. http://cfconventions.org/cf-conventions/cf-conventions.html

  2. \n
\n", slug = "references")),2021,list(name = "ncdfgeom", version = "1.1.1", authors = "David Blodgett"),list(destination = "dev", mode = "release", version_label = "default", version_tooltip = "Released version", in_dev = FALSE),list(root = "../", title = "ncdfgeom"),list(),list(type = "default", left = "
  • \n \n \n \n \n
  • \n
  • \n Get started\n
  • \n
  • \n Reference\n
  • \n
  • \n \n Articles\n \n \n \n \n
  • \n
  • \n Changelog\n
  • ", right = "
  • \n \n \n \n \n
  • "),list(.present = TRUE),list(version = "1.6.1"),FALSE