USEPA / elevatr

An R package for accessing elevation data
Other
204 stars 26 forks source link

get_elev_point issue related to sp::CRS #40

Closed hyoin-an closed 3 years ago

hyoin-an commented 3 years ago

Hello,

I wanted to extract elevation points from USGS Elevation Point Query Service using this package, and I tried your examples first (https://cran.r-project.org/web/packages/elevatr/vignettes/introduction_to_elevatr.html), but I keep getting the same error as below:

df_elev_epqs <- get_elev_point(examp_df, prj = prj_dd, src = "epqs") Error in sp::CRS(SRS_string = prj$wkt) : no arguments in initialization list

I did dig down a little bit and everything seems to work okay until it got to CRS() function. I also tried with developer version of the package, both windows (32 bit and 64bit) and Mac, older and newer version of R... but I encountered the same error every time. I even removed and reinstalled all the related packages as well. (elevatr, sp, sf, raster, and rgdal)

I would appreciate if you could help!

jhollist commented 3 years ago

Glad you are using elevatr but sorry you are having problems!

This example did work on my machine. So hard to say...

Can you report back results of sessionInfo(), rgdal::getGDALVersionInfo(), and rgdal::getPROJ4VersionInfo()?

hyoin-an commented 3 years ago

Thank you for the reply! Here are the results.

sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS 10.16

Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] grid stats graphics grDevices utils datasets methods base

other attached packages: [1] elevatr_0.3.4 mapdata_2.3.0 maps_3.3.0 ggplot2_3.3.3 fields_11.6
[6] spam_2.6-0 dotCall64_1.0-0 raster_3.4-5 sp_1.4-5

loaded via a namespace (and not attached): [1] Rcpp_1.0.6 pillar_1.4.7 compiler_3.6.3 class_7.3-17
[5] tools_3.6.3 ncdf4_1.17 lifecycle_0.2.0 tibble_3.0.5
[9] gtable_0.3.0 lattice_0.20-41 pkgconfig_2.0.3 rlang_0.4.10
[13] DBI_1.1.1 rstudioapi_0.13 rgdal_1.5-19 e1071_1.7-4
[17] withr_2.4.0 dplyr_1.0.3 generics_0.1.0 vctrs_0.3.6
[21] classInt_0.4-3 tidyselect_1.1.0 glue_1.4.2 sf_0.9-7
[25] R6_2.5.0 purrr_0.3.4 magrittr_2.0.1 units_0.6-7
[29] scales_1.1.1 codetools_0.2-18 ellipsis_0.3.1 assertthat_0.2.1
[33] colorspace_2.0-0 KernSmooth_2.23-18 munsell_0.5.0 crayon_1.3.4

rgdal::getGDALVersionInfo() [1] "GDAL 2.4.2, released 2019/06/28" rgdal::getPROJ4VersionInfo() [1] "Rel. 5.2.0, September 15th, 2018, [PJ_VERSION: 520]" attr(,"short") [1] 520

jhollist commented 3 years ago

Thanks. I was able to recreate the error on R 3.6.3. Don't have time right now to get a fix pushed. Be a few days at a minimum.

In the meantime, if you don't require R version 3.6.3, you could try a new version of R with the newer Rspatial packages and external libraries. I am 99% sure that will fix the problem. If you need version 3.6.3, I will hopefully have a fix on GitHub next week. CRAN will be a little longer than that.

hyoin-an commented 3 years ago

I appreciate it!

I actually need the version 3.6.3. of R since some libraries that my team is using don't work in the newest version... but I can totally wait till next week, and I believe this library would be very helpful for me. Thank you so much!

jhollist commented 3 years ago

Looked into this more and I don't think it is an R version thing. Looks like your GDAL and PROJ versions are out of date.

elevatr currently relies on PROJ >= 6 and GDAL >= 3 and this is because sp, sf, and rgdal have all moved to these newer versions. I bet if you update GDAL and PROJ on your machine these examples will work. This should satisfy the need to keep using the older version of R and still have elevatr work.

If you are unable to make the upgrades, you could try installing an older version of elevatr from CRAN. You will need to go back to version 0.2.0 and that should work as it still used the older PROJ and GDAL. You can install that with:

install.packages("https://cran.r-project.org/src/contrib/Archive/elevatr/elevatr_0.2.0.tar.gz", repos=NULL, type="source")

hyoin-an commented 3 years ago

Since I couldn't update GDAL with my current version of R, I tried with the older version of elevatr and it finally worked! Thank you so much for your help!

My last question in this case would be, is there any disadvantage for using an older version though instead of the most current version?

jhollist commented 3 years ago

@hyoin-an there shouldn't be any major issues with using the older versions. They still hit the same APIs so the results you get back with an older version should be the same as what you get with the newer versions (of course no promises that will always be the case as the APIs might change...) Most of the changes to get_elev_point that are currently on GitHub focus on usability kind of things. Thanks again for letting me know about this issue. I am going to close this issue, but if anything else comes up, let me know.