get_counts: counts pixel values according to their classes

Description Usage Arguments Value Examples

View source: R/rs_classify.R

Description

counts pixel values according to their classes

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
get_counts(
  ids = c(1, 2),
  position = NULL,
  imageFiles = NULL,
  buffersize = 1.5,
  outPrefix = "classified_index_",
  ext = ".tif",
  path = tempdir(),
  dropChars = 0
)

Arguments

ids

numeric. the ids used for the training

position

sp. spatialpoint object containing the centre target positions

imageFiles

raster* image/classification file

buffersize

numeric. radius in meters around position

outPrefix

character. out prefix string

ext

character. extension

path

character. output path

dropChars

numeric. number of characters that should be dropped at the end of the filename

Value

data frame containing the number of pixels per class

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
## Not run: 
##- required packages
 require(uavRst)

##- project root folder
 setwd(tempdir())


##- get the rgb image, chm and training data
 utils::download.file("https://github.com/gisma/gismaData/raw/master/uavRst/data/tutorial.zip",
                      "tutorial_data.zip")
 unzip(zipfile = "tutorial_data.zip" ,
         exdir = ".")

# read data
 position <- raster::shapefile("position.shp")
 imageFiles <-Sys.glob(paths = paste0("rgb*","tif"))
 imageTrainStack<-lapply(imageFiles, FUN=raster::stack)

## get counts
 df1<-get_counts(position = position,
                      ids = c(100,200),
               imageFiles = imageFiles,
                outPrefix = "",
                      ext = ".tif",
                     path = tempdir())
head(df1)
##+
## End(Not run)

uavRst documentation built on Dec. 30, 2019, 5:06 p.m.