Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Habitat Sampler
HabitatSampler
Commits
c9546ba9
Commit
c9546ba9
authored
Jul 08, 2021
by
Johannes Knoch
Browse files
adjusted the function like the scheme of saveSamplePoints
parent
c57ed9c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
R-package/R/save_files.r
View file @
c9546ba9
...
...
@@ -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
)),
]
res
ult
<-
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
=
res
ult
,
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
=
res
ult
,
layer
=
paste
(
"sel_SamplePoints_step_"
,
step
,
"_"
,
class_name
,
sep
=
""
),
dsn
=
paste
(
in_path
,
"sel_SamplePoints_step_"
,
step
,
"_"
,
class_name
,
".shp"
,
sep
=
""
),
driver
=
"ESRI Shapefile"
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment