grid_to_zone_fractions: Create fractional area of NetCDF grid cells to corresponding...

View source: R/workflows.R

grid_to_zone_fractionsR Documentation

Create fractional area of NetCDF grid cells to corresponding polygon features and vice versa

Description

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.

Usage

grid_to_zone_fractions(
  poly_path = "C:/Projects/ctry_glu_boundaries_moirai_combined_3p1_0p5arcmin.shp",
  raster_path = "C:/Projects/annual_area_harvested_irc_crop01_ha_30mn.asc",
  csv_name = NULL,
  perform_check = FALSE
)

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(s)

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


JGCRI/rgis documentation built on July 27, 2023, 1:47 p.m.