Commit f26ecc6c authored by Johannes Knoch's avatar Johannes Knoch
Browse files

all SamplePoints are saved now, not only those in the actual classified habitat

parent 03c1e40e
...@@ -66,11 +66,11 @@ save_kml <- function(outPath, step, raster, overwrite) { ...@@ -66,11 +66,11 @@ save_kml <- function(outPath, step, raster, overwrite) {
#' @param output_format format (character) of output; whether shp (default) or geojson #' @param output_format format (character) of output; whether shp (default) or geojson
#' @param ref_samples list of reference sample points #' @param ref_samples list of reference sample points
#' @param ref_switch vector with switch values #' @param ref_switch vector with switch values
#' @param threshold threshold #' @param num_models number of models used for the classification of a habitat
#' @param dummy_raster raster with probabilities for each pixel #' @param dummy_raster raster with probabilities for each pixel
#' #'
#' @return ESRI shapefiles/GeoJSON with name: SamplePoints_step_classname.shp/SamplePoints_step_classname.geojson #' @return ESRI shapefiles/GeoJSON with name: SamplePoints_step_classname.shp/SamplePoints_step_classname.geojson
#' 1) Point Shape/GeoJSON represents pixel that belong to selected habitat type and can be used as reference for further model building. #' 1) Point Shape/GeoJSON represents the pixels which were used to train the models for that habitat.
#' ESRI shapefiles have the same CRS as the input raster. GeoJSON files are in the standard CRS of GeoJSON (EPSG:4326). #' ESRI shapefiles have the same CRS as the input raster. GeoJSON files are in the standard CRS of GeoJSON (EPSG:4326).
#' #'
#' #'
...@@ -82,13 +82,13 @@ saveSamplePoints <- ...@@ -82,13 +82,13 @@ saveSamplePoints <-
output_format = c("shp", "geojson"), output_format = c("shp", "geojson"),
ref_samples, ref_samples,
ref_switch, ref_switch,
threshold, num_models,
dummy_raster) { dummy_raster) {
collect <- list() collect <- list()
j <- 0 j <- 0
dummy_raster[dummy_raster < threshold] <- NA dummy_raster[dummy_raster == num_models] <- NA
dummy_raster[dummy_raster >= threshold] <- 1 dummy_raster[dummy_raster > num_models] <- 1
###extract only class samples ###extract only class samples
for (i in 1:length(ref_samples)) { for (i in 1:length(ref_samples)) {
if (length(dim(ref_samples[[i]])) != 0) if (length(dim(ref_samples[[i]])) != 0)
...@@ -113,6 +113,7 @@ saveSamplePoints <- ...@@ -113,6 +113,7 @@ saveSamplePoints <-
result <- result[-which(is.na(res)), ] result <- result[-which(is.na(res)), ]
} }
raster::crs(result) <- raster::crs(dummy_raster) raster::crs(result) <- raster::crs(dummy_raster)
output_format <- match.arg(output_format) output_format <- match.arg(output_format)
if (output_format == "geojson") { if (output_format == "geojson") {
# Only transform is there points to be saved. # Only transform is there points to be saved.
...@@ -140,9 +141,11 @@ saveSamplePoints <- ...@@ -140,9 +141,11 @@ saveSamplePoints <-
} }
#' Sample Collection for Habitat Types #' Selected Sample Collection for Habitat Types
#' #'
#'Writes out a set of samples (SpatialPointsDataFrame) into ESRI shapefiles or a GeoJSON file for a selected habitat type. Each point represents a valid sample location that identifies the selected habitat type. #' Writes out a set of samples (SpatialPointsDataFrame) into ESRI shapefiles or a GeoJSON file for a selected habitat type.
#' Each point represents a valid sample location that identifies the selected habitat type. Only those points are selected
#' which lay in the habitat type selected by the user's input threshold.
#' #'
#' @param in_path file path (character) for results of habitat type sampling and probability mapping (same as outPath from function multi_Class_Sampling) #' @param in_path file path (character) for results of habitat type sampling and probability mapping (same as outPath from function multi_Class_Sampling)
#' @param step step number (numeric) #' @param step step number (numeric)
...@@ -150,7 +153,7 @@ saveSamplePoints <- ...@@ -150,7 +153,7 @@ saveSamplePoints <-
#' @param output_format format (character) of output; whether shp (default) or geojson #' @param output_format format (character) of output; whether shp (default) or geojson
#' #'
#' @return ESRI shapefiles/GeoJSON with name: SamplePoints_step_classname.shp/SamplePoints_step_classname.geojson #' @return ESRI shapefiles/GeoJSON with name: SamplePoints_step_classname.shp/SamplePoints_step_classname.geojson
#' 1) Point Shape/GeoJSON represents pixel that belong to selected habitat type and can be used as reference for further model building. #' 1) Point Shape/GeoJSON represents the pixels which belong to selected habitat type and can be used as reference for further model building.
#' ESRI shapefiles have the same CRS as the input raster. GeoJSON files are in the standard CRS of GeoJSON (EPSG:4326). #' ESRI shapefiles have the same CRS as the input raster. GeoJSON files are in the standard CRS of GeoJSON (EPSG:4326).
#' #'
#' #'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment