pr_extract_subarea: FUNCTION_TITLE

Description Usage Arguments Value Author(s) Examples

View source: R/pr_extract_subarea.R

Description

FUNCTION_DESCRIPTION

Usage

1
2
pr_extract_subarea(in_mosaics_folder, in_mask, out_folder, what = c("decirc",
  "orig"))

Arguments

in_mosaics_folder

folder containing the tiff and RData mosaics. (e.g., "/home/lb/my_data/prasia/Data/orig_mosaics")

in_mask

polygon on to which data should be extracted

out_folder

folder where results should be stored

Value

Cropped reasters are saved in the specified output folder.

Author(s)

Lorenzo Busetto, phD (2017) lbusett@gmail.com

Examples

 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
## Not run: 
 main_folder <- "/home/lb/my_data/prasia/Data"
 mosaic_folder <- "/home/lb/my_data/prasia/Data/orig_mosaics"
 in_shp <- read_vect(file.path(main_folder, "vector/Ricetlas/riceatlas_asia_reshuffled.shp"))

 # Suppose you want to extract data for Region: "Region_3_-_Central_Luzon" :
 # --> extract it from the full shapefile

 Region_name <- ""Region_3_-_Central_Luzon""

 in_mask <- dplyr::filter(in_shp, Region == Region_name)
 in_mask <- unique(in_mask[1:4]) # this is needed to remove duplicate polygons
 in_mask
 plot_vect(in_mask, fill_var = "ID_name")

 # in_mask contains one polygon for each sub_region of "Region_3_-_Central_Luzon"

 # Define the output folder
 out_folder  <- file.path("/home/lb/my_data/prasia/mosaics/ordered/subsets/",
   Region_name)
 out_folder

 # you have all you need: location of the mosaic rasters, a vector where to
 # cut and an output folder

 pr_extract_subarea(mosaic_folder,
                in_mask,
                out_folder)

 # You will find the cropped rasters in "out_folder"
 
## End(Not run)

lbusett/phenoriceR documentation built on May 18, 2019, 9:17 p.m.