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

renamed parameters due to new standard; deleted unnecessary variable

parent a63d68d1
......@@ -2,9 +2,9 @@
#'
#'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.
#'
#' @param inPath 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 className name (character) of habitat type for which samples should be selected
#' @param class_name name (character) of habitat type for which samples should be selected
#' @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
......@@ -15,13 +15,13 @@
#' @export
###write out selected samples
writeOutSamples <- function (inPath, step, className, output_format = c("shp", "geojson")) {
writeOutSamples <- function (in_path, step, class_name, output_format = c("shp", "geojson")) {
paste(inPath, "step_", step, "_", className, ".tif", sep = "")
run1 <- get(load(paste(inPath, "Run", step, sep = "")))
load(paste(inPath, "threshold_step_", step, sep = ""))
paste(in_path, "step_", step, "_", class_name, ".tif", sep = "")
run1 <- get(load(paste(in_path, "Run", step, sep = "")))
load(paste(in_path, "threshold_step_", step, sep = ""))
dummy_sample <-
raster::raster(paste(inPath, "step_", step, "_", className, ".tif", sep =
raster::raster(paste(in_path, "step_", step, "_", class_name, ".tif", sep =
""))
length_threshold <- length(threshold)
......@@ -59,26 +59,24 @@ writeOutSamples <- function (inPath, step, className, output_format = c("shp", "
output_format <- match.arg(output_format)
if (output_format == "geojson") {
crs_dummy <- sp::proj4string(dummy_sample)
raster::crs(res) <- crs_dummy
raster::crs(res) <- sp::proj4string(dummy_sample)
res <- sp::spTransform(res, sp::CRS("+init=epsg:4326"))
rgdal::writeOGR(
obj = res,
layer = paste("SamplePoints_step_", step, "_", className, sep = ""),
dsn = paste(inPath, "SamplePoints_step_", step, "_", className, ".geojson", sep = ""),
layer = paste("SamplePoints_step_", step, "_", class_name, sep = ""),
dsn = paste(in_path, "SamplePoints_step_", step, "_", class_name, ".geojson", sep = ""),
driver = "GeoJSON",
check_exists = TRUE,
overwrite_layer = TRUE
)
} else {
crs_dummy <- sp::proj4string(dummy_sample)
raster::crs(res) <- crs_dummy
raster::crs(res) <- sp::proj4string(dummy_sample)
rgdal::writeOGR(
obj = res,
layer = paste("SamplePoints_step_", step, "_", className, sep = ""),
dsn = paste(inPath, "SamplePoints_step_", step, "_", className, ".shp", sep = ""),
layer = paste("SamplePoints_step_", step, "_", class_name, sep = ""),
dsn = paste(in_path, "SamplePoints_step_", step, "_", class_name, ".shp", sep = ""),
driver = "ESRI Shapefile",
check_exists = TRUE,
overwrite_layer = TRUE
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/WriteOutSamples.r
% Please edit documentation in R/writeOutSamples.r
\name{writeOutSamples}
\alias{writeOutSamples}
\title{Sample Collection for Habitat Types}
\usage{
writeOutSamples(inPath, step, className, output_format = c("shp", "geojson"))
writeOutSamples(in_path, step, class_name, output_format = c("shp", "geojson"))
}
\arguments{
\item{inPath}{file path (character) for results of habitat type sampling and probability mapping (same as outPath from function multi_Class_Sampling)}
\item{in_path}{file path (character) for results of habitat type sampling and probability mapping (same as outPath from function multi_Class_Sampling)}
\item{step}{step number (numeric)}
\item{className}{name (character) of habitat type for which samples should be selected}
\item{class_name}{name (character) of habitat type for which samples should be selected}
\item{output_format}{format (character) of output; whether shp (default) or geojson}
}
\value{
ESRI shapefiles/GeoJSON with name: SamplePoints_step_classname.shp/SamplePoints_step_classname.geojson
\enumerate{
\item Point Shape/GeoJSON represents pixel that belong to selected habitat type and can be used as reference for further model building
\item Point Shape/GeoJSON represents pixel that 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).
}
}
\description{
......
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