Description Usage Arguments Value See Also Examples
PolyToRaster
takes a NetCDF geogrid as well as a polygon
and return the attribute requested from polygon as a raster file.
1 2 3 4 |
geoFile |
The geogrid NetCDF file. |
useRfc |
Logical: if |
polygon |
SpatialPolygon* This is used if you want to use a polygon already loaded in memory. |
polygonAddress |
Character: Address to where polygonShapeFile is located. |
polygonShapeFile |
Character: Name of a polygon shapefile. |
field |
Numeric or character: The value(s) to be transferred. This can be a single number, or a vector of numbers that has the same length as the number of spatial features (polygons). |
fun |
Function or character: To determine what values to assign to cells
that are covered by multiple spatial features. You can use functions such as
|
mask |
Logical: If |
maskValue |
Numeric: The value to be used for creating the mask. Default is |
getCoverMask |
Logical: If |
getCover |
Logical: If |
plot.it |
Logical: If |
parallel |
Logical: will be used only if |
return a RasterLayer or a RasterStack.
Other geospatial: ExportGeogrid
,
GetGeogridIndex
,
GetGeogridSpatialInfo
,
GetPoly
, GetProj
,
GetRfc
, GetTimeZone
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ## Not run:
#Example 1:
# To rasterize the rfc SpatialPolygonsDataFrame :
r <- PolyToRaster(geoFile = "/glade/scratch/arezoo/IOC/ESMF/geo_em.d01.nc.conus_1km",
useRfc = TRUE,
field ="BASIN_ID")
# You can get the numbres assign to each BAISN_ID like :
# Example 2:
# To return a mask with default value of 1 inside the polygons and NA outside
r1 <- PolyToRaster(geoFile = "/glade/scratch/arezoo/IOC/ESMF/geo_em.d01.nc.conus_1km",
useRfc = TRUE,
field ="BASIN_ID",
mask = TRUE)
# Example 3:
# To return a mask with value of 5 inside the polygons and NA outside
r2 <- PolyToRaster(geoFile = "/glade/scratch/arezoo/IOC/ESMF/geo_em.d01.nc.conus_1km",
useRfc = TRUE,
field ="BASIN_ID",
mask = TRUE,
maskValue = 5)
# Example 4:
# To return a raster with values to be the BASIN_ID (convert character to integer numbers)
# with fraction of each grid cell that is covered by the polygons
r3 <- PolyToRaster(geoFile = "/glade/scratch/arezoo/IOC/ESMF/geo_em.d01.nc.conus_1km",
useRfc = TRUE,
field ="BASIN_ID",
getCover = TRUE,
parallel = TRUE))
plot(r3)
# Example 5:
# To read a shapefile (polygon) from disk and
# return a raster with values of field
# with fraction of each grid cell that is covered by the polygons
r4 <- PolyToRaster(geoFile = "/glade/scratch/arezoo/IOC/ESMF/geo_em.d01.nc.conus_1km",
polygonAddress= "/glade/scratch/arezoo/QPF_verification_rwrfhydro/gis",
polygonShapeFile= "HUC4",
field ="HUC4")
plot(r4)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.