create_csv: Create Training Data CSV

Description Usage Arguments Examples

Description

Function to extract the pixel values in a high resolution classified image that correspond to individual randomly selected moderate resolution pixels and then calculates the percent of the classified image pixels that represent your cover type of interest. In other words, if your high resolution image has a pixel size of 1m and your moderate resolution image has a pixel size of 30m the sampling process would take a block of 900 of the 1m resolution pixels that correspond to a single 30m pixel and calculate the percentage of the 1m pixels that are forest. For example, if there were 600 forest pixels and 300 non-forest pixels the value given for the output pixel would be 0.67 since 67 there are clouds or other no-data values in the high resolution image the following logic will apply. If the total no-data values for a block of high resolution pixels is greater than or equal to a user defined threshold (we will use 10 it will not be included in the training data set since there is too much missing data to provide a reliable cover percentage. If the cloud cover is less then 10 from the total number of pixels when calculating the percent forest cover. Adapted from script by Ned Horning [horning-at-amnh.org]

Usage

1
create_csv(inPred, inClass, numSamps, fromVals, toVals)

Arguments

inClass

Name and path for the input classified image (High res)

numSamps

Number of samples to be selected

fromVals

vector of the values in classified image

toVals

vector which values will be changes too

inPredImage

Name and path for the input image that will be used for predictions (Landsat/MODIS)

ndPred

No data value for the prediction image (normally 0)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
numSamps <- 2000
inPredImage <-"F:\\Projects\\Shrub_cover\\NGI_aerial_imagery\\shrub_masks\\KNP_shrubmask1.tif"
inPredImage <-"F:\\Projects\\Shrub_trends\\Ch3_shrub_cover\\Landsat_SA_AEA.tif"
ndPred <- 0
Class numbers that will be mapped using the following scheme:
0 = no data such as background, clouds and shadow
1 = class for which percent cover is being calculated
2 = all other land cover classes
fromVals <- c(0,1, 2, 3)
toVals <-   c(2,1, 2, 2)

Tomhigg/fracCover documentation built on May 9, 2019, 5:11 p.m.