Create fractional area of NetCDF grid cells to corresponding polygon features and vice versa. This function creates an output CSV file with attributes from the input polygon features and their spatially intersecting NetCDF grid cells for each time step in the file. The user can chose to save intermediate step shapefiles as well. Fields that describe the fraction of a polygon that is in a grid cell (zone_frac) and the fraction of a grid cell that is in a zone (cell_frac) are output in the final CSV.

grid_to_zone_fraction(poly_path, ncdf_path, out_csv, to_crs = 3857,
  save_isct = NULL, save_fishnet = NULL, save_ncpts = NULL,
  filter_na = TRUE)

Arguments

poly_path

character. A full path with file name and extension to the input polygon shapefile

ncdf_path

character. A full path with file name and extension to the input NetCDF file

out_csv

character. A full path with file name and extension for the output CSV file

to_crs

int. The EPSG number of a projected coordinate reference system. Must be projected and not geographic due to assumptions that sf::st_intersection makes when using geographic systems. Default is EPSG:3857, WGS 84 / Pseudo-Mercator - Spherical Mercator used by Google Maps, OpenStreetMap, etc.

save_isct

character. A full path with file name and extension (shp) for the output intersecting polygons to fishnet grid shapefile if desired as an output. Defualt NULL.

save_fishnet

character. A full path with file name and extension (shp) for the output fishnet grid shapefile if desired as an output. Defualt NULL.

save_ncpts

character. A full path with file name and extension (shp) for the output NetCDF grid centroids that intersect the polygon fishnet shapefile if desired as an output. Defualt NULL.

filter_na

boolean. TRUE (default) to remove NA land values where a fishnet grid intersected a polygon but the NetCDF had no underlying value; FALSE to keep NA

Value

data.frame

Author

Chris R. Vernon (chris.vernon@pnnl.gov)