Commit c57ed9c6 authored by Romulo Pereira Goncalves's avatar Romulo Pereira Goncalves
Browse files

We should reset result and not res, and then use result.

parent 9f38b38e
...@@ -110,17 +110,17 @@ saveSamplePoints <- ...@@ -110,17 +110,17 @@ saveSamplePoints <-
res <- raster::extract(dummy_raster, result) res <- raster::extract(dummy_raster, result)
if (length(which(is.na(res))) > 0) { if (length(which(is.na(res))) > 0) {
res <- result[-which(is.na(res)), ] result <- result[-which(is.na(res)), ]
} }
raster::crs(res) <- 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.
if (nrow(res) > 0) { if (nrow(result) > 0) {
res <- sp::spTransform(res, sp::CRS("+init=epsg:4326")) result <- sp::spTransform(result, sp::CRS("+init=epsg:4326"))
} }
rgdal::writeOGR( rgdal::writeOGR(
obj = res, obj = result,
layer = paste("SamplePoints_step_", step, "_", class_name, sep = ""), layer = paste("SamplePoints_step_", step, "_", class_name, sep = ""),
dsn = paste(in_path, "SamplePoints_step_", step, "_", class_name, ".geojson", sep = ""), dsn = paste(in_path, "SamplePoints_step_", step, "_", class_name, ".geojson", sep = ""),
driver = "GeoJSON", driver = "GeoJSON",
...@@ -129,7 +129,7 @@ saveSamplePoints <- ...@@ -129,7 +129,7 @@ saveSamplePoints <-
) )
} else { } else {
rgdal::writeOGR( rgdal::writeOGR(
obj = res, obj = result,
layer = paste("SamplePoints_step_", step, "_", class_name, sep = ""), layer = paste("SamplePoints_step_", step, "_", class_name, sep = ""),
dsn = paste(in_path, "SamplePoints_step_", step, "_", class_name, ".shp", sep = ""), dsn = paste(in_path, "SamplePoints_step_", step, "_", class_name, ".shp", sep = ""),
driver = "ESRI Shapefile", 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