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

adjusted the function like the scheme of saveSamplePoints

parent c57ed9c6
......@@ -191,19 +191,19 @@ writeOutSamples <- function(in_path, step, class_name, output_format = c("shp",
result <- do.call(rbind, collect)
res <- raster::extract(dummy_sample, result)
res <- raster::extract(dummy_raster, result)
if (length(which(is.na(res))) > 0) {
res <- result[-which(is.na(res)), ]
result <- result[-which(is.na(res)), ]
}
raster::crs(result) <- raster::crs(dummy_raster)
output_format <- match.arg(output_format)
if (output_format == "geojson") {
raster::crs(res) <- sp::proj4string(dummy_sample)
res <- sp::spTransform(res, sp::CRS("+init=epsg:4326"))
# Only transform is there points to be saved.
if (nrow(result) > 0) {
result <- sp::spTransform(result, sp::CRS("+init=epsg:4326"))
}
rgdal::writeOGR(
obj = res,
obj = result,
layer = paste("sel_SamplePoints_step_", step, "_", class_name, sep = ""),
dsn = paste(in_path, "sel_SamplePoints_step_", step, "_", class_name, ".geojson", sep = ""),
driver = "GeoJSON",
......@@ -211,10 +211,8 @@ writeOutSamples <- function(in_path, step, class_name, output_format = c("shp",
overwrite_layer = TRUE
)
} else {
raster::crs(res) <- sp::proj4string(dummy_sample)
rgdal::writeOGR(
obj = res,
obj = result,
layer = paste("sel_SamplePoints_step_", step, "_", class_name, sep = ""),
dsn = paste(in_path, "sel_SamplePoints_step_", step, "_", class_name, ".shp", sep = ""),
driver = "ESRI Shapefile",
......
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