Closed mwennde closed 2 years ago
Unfortunately, this is a package install, control issue that the spatialEco package has no control over. These required package environments are only designated by a package, with R managing the actually dependency. If a packages is not finding a required environment it either does not exist or something about how R is managing library paths is not allowing access.
It looks like you are aiming at the “library” directory under your R install so, personal libraries should not be a problem here. Do you have root permissions for this directory? At this point, all I can recommend is making sure that your permissions are open for the library and, delete the sf install and reinstall it. I would also suggest using the dependencies=TRUE argument in your call to remotes::install_github.
Please let me know if I can help further.
Best, Jeff
Jeffrey S. Evans, Ph.D., | Senior Landscape Ecologist & Biometrician The Nature Conservancy | Global Protect, Science Visiting Professor | University of Wyoming | Zoology & Physiology Laramie, WY | @.**@.> | (970) 672-6766<tel:(970)%20672-6766>
From: mwennde @.> Sent: Sunday, February 6, 2022 8:16 AM To: jeffreyevans/spatialEco @.> Cc: Jeffrey Evans @.>; Mention @.> Subject: [jeffreyevans/spatialEco] installation to get sample.distance (Issue #42)
@jeffreyevanshttps://github.com/jeffreyevans I have tried installing spatialEco (using remotes::install_github("jeffreyevans/spatialEco")) to get the version with sample. distance but I get the error sf is not found yet I have sf 1.0.6 version installed ( local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) if(nchar(pkg)) library(pkg, character.only=TRUE)}) Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE Warning message: package ‘sf’ was built under R version 4.2.0 )
Kindly assist
` update.packages(ask='graphics',checkBuilt=TRUE) Warning: package 'class' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'foreign' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'MASS' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'Matrix' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'nlme' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'nnet' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'rpart' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'spatial' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated
utils:::menuInstallLocal() package ‘spatialEco’ successfully unpacked and MD5 sums checked remotes::install_github("jeffreyevans/spatialEco") Downloading GitHub repo @.*** Skipping 10 packages ahead of CRAN: numDeriv, colorspace, timeDate, zoo, sandwich, latticeExtra, abind, rgdal, multcomp, yaImpute
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
√ checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION'
checking DESCRIPTION meta-information ...
√ checking DESCRIPTION meta-information
Installing package into ‘C:/Users/pc/Documents/R/win-library/4.1’ (as ‘lib’ is unspecified)
`
— Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/spatialEco/issues/42, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH74OIR6OICWZE46GPG3UZ2GE3ANCNFSM5NVOKYKA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>
Also, as a follow up, you can source a function from GitHub using the devtools package. However, be cautious doing this with packages because it will not bring along any dependencies (eg., other required functions from the package). In the case of subsample.distance it is safe but, it requires the sp package be installed to work.
devtools::source_url("https://github.com/jeffreyevans/spatialEco/blob/master/R/subsample.distance.R?raw=TRUE ")
Best, Jeff
From: mwennde @.> Sent: Sunday, February 6, 2022 8:16 AM To: jeffreyevans/spatialEco @.> Cc: Jeffrey Evans @.>; Mention @.> Subject: [jeffreyevans/spatialEco] installation to get sample.distance (Issue #42)
@jeffreyevanshttps://github.com/jeffreyevans I have tried installing spatialEco (using remotes::install_github("jeffreyevans/spatialEco")) to get the version with sample. distance but I get the error sf is not found yet I have sf 1.0.6 version installed ( local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) if(nchar(pkg)) library(pkg, character.only=TRUE)}) Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE Warning message: package ‘sf’ was built under R version 4.2.0 )
Kindly assist
` update.packages(ask='graphics',checkBuilt=TRUE) Warning: package 'class' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'foreign' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'MASS' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'Matrix' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'nlme' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'nnet' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'rpart' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'spatial' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated
utils:::menuInstallLocal() package ‘spatialEco’ successfully unpacked and MD5 sums checked remotes::install_github("jeffreyevans/spatialEco") Downloading GitHub repo @.*** Skipping 10 packages ahead of CRAN: numDeriv, colorspace, timeDate, zoo, sandwich, latticeExtra, abind, rgdal, multcomp, yaImpute
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
√ checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION'
checking DESCRIPTION meta-information ...
√ checking DESCRIPTION meta-information
Installing package into ‘C:/Users/pc/Documents/R/win-library/4.1’ (as ‘lib’ is unspecified)
`
— Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/spatialEco/issues/42, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH74OIR6OICWZE46GPG3UZ2GE3ANCNFSM5NVOKYKA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>
It is looking like there are some version dependency conflicts going on in terra and sf under R 4.1.2. The terra package needs version 1.5-1 to run under R 4.1.2 and does not update automatically when another package is installed that requires it as a dependency. So, if it is a previous version you will receive an error. Lately, it has been taking some time for packages to be converted to binary under windows distribution so, unless you have RTools installed and your package defaults are set to “compile from source”, then any requested update is skipped. Every once in a while, these versioning conflicts occur and eventually resolve themselves, as they did with the release of R 4.0.0. I would recommend performing fresh installs of sf, sp, terra, raster and, rgdal before installing spatialEco.
BTW, the subsample.distance
function is available in the stable CRAN release. Why are you downloading the development version?
Best, Jeff
From: mwennde @.> Sent: Sunday, February 6, 2022 8:16 AM To: jeffreyevans/spatialEco @.> Cc: Jeffrey Evans @.>; Mention @.> Subject: [jeffreyevans/spatialEco] installation to get sample.distance (Issue #42)
@jeffreyevanshttps://github.com/jeffreyevans I have tried installing spatialEco (using remotes::install_github("jeffreyevans/spatialEco")) to get the version with sample. distance but I get the error sf is not found yet I have sf 1.0.6 version installed ( local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) if(nchar(pkg)) library(pkg, character.only=TRUE)}) Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE Warning message: package ‘sf’ was built under R version 4.2.0 )
Kindly assist
` update.packages(ask='graphics',checkBuilt=TRUE) Warning: package 'class' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'foreign' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'MASS' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'Matrix' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'nlme' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'nnet' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'rpart' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated Warning: package 'spatial' in library 'C:/Program Files/R/R-4.1.2/library' will not be updated
utils:::menuInstallLocal() package ‘spatialEco’ successfully unpacked and MD5 sums checked remotes::install_github("jeffreyevans/spatialEco") Downloading GitHub repo @.*** Skipping 10 packages ahead of CRAN: numDeriv, colorspace, timeDate, zoo, sandwich, latticeExtra, abind, rgdal, multcomp, yaImpute
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
√ checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION'
checking DESCRIPTION meta-information ...
√ checking DESCRIPTION meta-information
Installing package into ‘C:/Users/pc/Documents/R/win-library/4.1’ (as ‘lib’ is unspecified)
`
— Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/spatialEco/issues/42, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH74OIR6OICWZE46GPG3UZ2GE3ANCNFSM5NVOKYKA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>
@jeffreyevans Thank you Jeffrey for addressing my issue. Initially was using a sample. annulus but because of proj4string could not get any output (I need to get a random sample for my (a 4 kilometres minimum distance between any pair of control and treatment village. )
subsample.distance picks only one village sub.s <- subsample.distance(s, size = 50, d = 500, d.max = 4000)
(I have 120 villages and 50 should be in the treatment)
Then I saw the discussion suggesting the use of sample. distance [https://gis.stackexchange.com/questions/299625/random-selection-of-points-in-spatialpointsdataframe-r-object-with-distance-cons]
`> library(sp)
library(spatialEco)
Attaching package: ‘spatialEco’
The following object is masked from ‘package:dplyr’:
combine
Warning message: package ‘spatialEco’ was built under R version 4.2.0
data(meuse) coordinates(meuse) <- ~ x+y sub.meuse <- sample.distance(meuse, n = p, d = 500, trace = TRUE)
Error in sample.distance(meuse, n = p, d = 500, trace = TRUE) : could not find function "sample.distance" plot(meuse,pch=19, main="min dist = 500") points(sub.meuse, pch=19, col="red") Ire `
The post you are referencing is from 2018 so, the function got moved into the package long ago. Please note that it is “subsample.distance” due to it being a subsampling and not a sample generation approach.
What was your problem with sample.annulus? If the data is in a geographic projection rgeos does not like it and issues an error regarding planar coordinates. Were you missing a projection definition or was it geographic? This sounds like a more appropriate solution for your problem and I can likely get the function working for you without too much work.
-jeff
From: mwennde @.> Sent: Tuesday, February 8, 2022 12:51 PM To: jeffreyevans/spatialEco @.> Cc: Jeffrey Evans @.>; Mention @.> Subject: Re: [jeffreyevans/spatialEco] installation to get sample.distance (Issue #42)
Thank you Jeffrey for addressing my issue. Initially was using a sample. annulus but because of proj4string could not get any output (I need to get a random sample for my (a 4 kilometres minimum distance between any pair of control and treatment village. )
subsample.distance picks only one village sub.s <- subsample.distance(s, size = 50, d = 500, d.max = 4000) (I have 120 villages and 50 should be in the treatment)
Then I saw the discussion suggesting the use of sample. distance [https://gis.stackexchange.com/questions/299625/random-selection-of-points-in-spatialpointsdataframe-r-object-with-distance-conshttps://gis.stackexchange.com/questions/299625/random-selection-of-points-in-spatialpointsdataframe-r-object-with-distance-cons]
`> library(sp)
library(spatialEco)
Attaching package: ‘spatialEco’
The following object is masked from ‘package:dplyr’:
combine
Warning message: package ‘spatialEco’ was built under R version 4.2.0
data(meuse) coordinates(meuse) <- ~ x+y sub.meuse <- sample.distance(meuse, n = p, d = 500, trace = TRUE) Error in sample.distance(meuse, n = p, d = 500, trace = TRUE) : could not find function "sample.distance" plot(meuse,pch=19, main="min dist = 500") points(sub.meuse, pch=19, col="red") Ire `
— Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/spatialEco/issues/42#issuecomment-1033000109, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH7YIU7AYIKC7QYT5WTLU2FXZ5ANCNFSM5NVOKYKA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>
The error with sample.annulus . ` library(sp)
library(rgeos) data(meuse) coordinates(meuse) <- ~x+y proj4string(meuse) <- CRS("+init=epsg:28992") xy <- meuse[2,] rs100 <- sample.annulus(xy, r1=50, r2=100, n = 50, type = "random") Warning message: In proj4string(obj) : CRS object has comment, which is lost in output; in tests, see https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html `
This is a non-error, just a warning message regarding the way proj4 comments and datums are now being handled with the changes to PROJ and GDAL. This warning message is not effecting output. Do note that warning messages are common in R and often do not effect output whereas and error message indicates that the function has stopped with an error condition, without providing output.
You can suppress this message, coming from rgdal, by issuing: options("rgdal_show_exportToProj4_warnings"="none") before adding any packages or by putting it in your start up “Rprofile.site” file.
In fact, you can just sidestep the entire issue and assign a WKT2 projection format to your object in the first place (following the new standard). For an sp object you have to access the "proj4string" slot whereas for sf objects you can simply use an assignment pipe st_crs(obj) <- st_crs(EPSG) Here is an example on the code block that you sent.
library(sp)
library(spatialEco)
rgdal::rgdal_extSoftVersion()
data(meuse, package = "sp")
coordinates(meuse) <- ~x+y
slot(meuse, "proj4string") <- CRS(SRS_string = "EPSG:28992")
xy <- meuse[2,]
rs100 <- sample.annulus(xy, r1=50, r2=100, n = 50, type = "random")
rs200 <- sample.annulus(xy, r1=100, r2=200, n = 50, type = "random")
plot(rs200, pch=20, col="red")
points(rs100, pch=20, col="blue")
points(xy, pch=20, cex=2, col="black")
box()
legend("topright", legend=c("50-100m", "100-200m", "source"),
pch=c(20,20,20), col=c("blue","red","black"))
#### Or, for projection assignment for an sf object (although you can do this
#### directly in the st_as_sf function with the crs argument).
data(meuse, package = "sp")
meuse <- st_as_sf(meuse, coords = c("x", "y"), = "constant")
st_crs(meuse) <- st_crs(28992)
-jeff
From: mwennde @.> Sent: Tuesday, February 8, 2022 2:46 PM To: jeffreyevans/spatialEco @.> Cc: Jeffrey Evans @.>; Mention @.> Subject: Re: [jeffreyevans/spatialEco] installation to get sample.distance (Issue #42)
The error with sample.annulus . ` library(sp)
library(rgeos) data(meuse) coordinates(meuse) <- ~x+y proj4string(meuse) <- CRS("+init=epsg:28992") xy <- meuse[2,] rs100 <- sample.annulus(xy, r1=50, r2=100, n = 50, type = "random") Warning message: In proj4string(obj) : CRS object has comment, which is lost in output; in tests, see https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.htmlhttps://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html `
— Reply to this email directly, view it on GitHubhttps://github.com/jeffreyevans/spatialEco/issues/42#issuecomment-1033092458, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLKH75ZGINX6BEO2AD635LU2GFJJANCNFSM5NVOKYKA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.**@.>>
Thank you. I will then use the sample. annulus
@jeffreyevans I have tried installing spatialEco (using remotes::install_github("jeffreyevans/spatialEco")) to get the version with sample. distance but I get the error sf is not found yet I have sf 1.0.6 version installed
( local({pkg <- select.list(sort(.packages(all.available = TRUE)),graphics=TRUE) if(nchar(pkg)) library(pkg, character.only=TRUE)}) Linking to GEOS 3.9.1, GDAL 3.3.2, PROJ 7.2.1; sf_use_s2() is TRUE Warning message: package ‘sf’ was built under R version 4.2.0
)Kindly assist
`
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION' ...
√ checking for file 'C:\Users\pc\AppData\Local\Temp\RtmpiKsqfA\remotes31d83a9d3d34\jeffreyevans-spatialEco-76d5739/DESCRIPTION'
preparing 'spatialEco': (2.3s) checking DESCRIPTION meta-information ...
checking DESCRIPTION meta-information ...
√ checking DESCRIPTION meta-information
checking for LF line-endings in source and make files and shell scripts (377ms)
checking for empty or unneeded directories
building 'spatialEco_1.3-8.tar.gz'
Installing package into ‘C:/Users/pc/Documents/R/win-library/4.1’ (as ‘lib’ is unspecified)
annulus.matrix html
ants html
background html
bearing.distance html
breeding.density html
built.index html
cgls_urls html
chae html
chen html
class.comparison html
classBreaks html
collinear html
combine html
concordance html
conf.interval html
convexHull html
cor.data html
correlogram html
cross.tab html
crossCorrelation html
csi html
curvature html
dahi html
date_seq html
daymet.point html
daymet.tiles html
dispersion html
dissection html
divergence html
download.daymet html
download.hansen html
download.prism html
effect.size html
elev html
erase.point html
explode html
extract.vertices html
focal.lmetrics html
fuzzySum html
gaussian.kernel html
geo.buffer html
group.pdf html
hexagons html
hli html
hli.pt html
hsp html
hybrid.kmeans html
idw.smoothing html
impute.loess html
insert html
insert.values html
is.empty html
is.whole html
kde.2D html
kendall html
kl.divergence html
knn html
land.metrics html
local.min.max html
loess.boot html
loess.ci html
logistic.regression html
max_extent html
moments html
morans.plot html
mwCorr html
nni html
nth.values html
o.ring html
oli.asw html
optimal.k html
optimized.sample.variance html
outliers html
overlap html
parea.sample html
parse.bits html
partial.cor html
plot.effect.size html
plot.loess.boot html
point.in.poly html
poly.regression html
polyPerimeter html
polygon_extract html
pp.subsample html
print.cross.cor html
print.effect.size html
print.loess.boot html
proximity.index html
pseudo.absence html
pu html
quadrats html
random.raster html
raster.Zscore html
raster.change html
raster.deviation html
raster.downscale html
raster.entropy html
raster.gaussian.smooth html
raster.invert html
raster.kendall html
raster.mds html
raster.modified.ttest html
raster.moments html
raster.transformation html
raster.vol html
rasterCorrelation html
rasterDistance html
remove.holes html
rm.ext html
rotate.polygon html
sa.trans html
sample.annulus html
sample.line html
sample.poly html
sampleTransect html
sar html
se.news html
separability html
sg.smooth html
shannons html
shift html
similarity html
smooth.time.series html
sobal html
sp.kde html
sp.na.omit html
spatial.select html
spectral.separability html
spherical.sd html
srr html
stratified.random html
subsample.distance html
summary.cross.cor html
summary.effect.size html
summary.loess.boot html
swvi html
time_to_event html
topo.distance html
tpi html
trasp html
trend.line html
tri html
vrm html
winsorize html
wt.centroid html
zonal.stats html
copying figures building package indices testing if installed package can be loaded from temporary location arch - i386 Error: package or namespace load failed for 'spatialEco' in library.dynam(lib, package, package.lib): DLL 'sf' not found: maybe not installed for this architecture? Error: loading failed Execution halted *** arch - x64 ERROR: loading failed for 'i386'