ropensci / rnaturalearth

An R package to hold and facilitate interaction with natural earth map data :earth_africa:
http://ropensci.github.io/rnaturalearth/
Other
214 stars 24 forks source link

ne_countries() with returnclass = "sf" crashes in CentOS 7 Linux #38

Closed John-R-Wallace-NOAA closed 4 weeks ago

John-R-Wallace-NOAA commented 3 years ago

ne_countries() function in rnaturalearth version 0.2.0 under R version 4.0.1 on a Linux server:

Operating System: CentOS Linux 7 (Core) Architecture: x86-64

crashes:

  > world <- rnaturalearth::ne_countries(scale = "medium", returnclass = "sf")

  *** caught segfault ***
 address (nil), cause 'unknown'

 Traceback:
  1: CPL_crs_from_input(x)
  2: make_crs(x)
  3: st_crs.character(x@projargs)
  4: st_crs(x@projargs)
  5: st_crs.CRS(x@proj4string)
  6: st_crs(x@proj4string)
  7: append(lst, list(crs = st_crs(x@proj4string), precision = precision))
  8: do.call(st_sfc, append(lst, list(crs = st_crs(x@proj4string),     precision = precision)))
  9: structure(sfc, bbox = bb)
 10: handle_bbox(do.call(st_sfc, append(lst, list(crs = st_crs(x@proj4string),     precision = precision))), x)
 11: st_as_sfc.SpatialPolygons(sp::geometry(x), ...)
 12: st_as_sfc(sp::geometry(x), ...)
 13: st_as_sf.Spatial(x)
 14: st_as_sf(x)
 15: ne_as_sf(spdf[filter, ], returnclass)
 16: rnaturalearth::ne_countries(scale = "medium", returnclass = "sf")

 Possible actions:
 1: abort (with core dump, if enabled)
 2: normal R exit
 3: exit R without saving workspace
 4: exit R saving workspace

Using returnclass = "sp" works but is not what is needed.

Downloading directly from this repo (using the remotes package) did not help.

PMassicotte commented 1 year ago

I am not able to reproduce it. From a Docker image:

> head(rnaturalearth::ne_countries(scale = "medium", returnclass = "sf"))[, 1:2]
Simple feature collection with 6 features and 2 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -70.06611 ymin: -18.01973 xmax: 74.89131 ymax: 60.40581
CRS:           +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
  scalerank      featurecla                       geometry
0         3 Admin-0 country MULTIPOLYGON (((-69.89912 1...
1         1 Admin-0 country MULTIPOLYGON (((74.89131 37...
2         1 Admin-0 country MULTIPOLYGON (((14.19082 -5...
3         1 Admin-0 country MULTIPOLYGON (((-63.00122 1...
4         1 Admin-0 country MULTIPOLYGON (((20.06396 42...
5         3 Admin-0 country MULTIPOLYGON (((20.61133 60...
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10             rnaturalearth_0.1.0     magrittr_2.0.3         
 [4] units_0.8-1             tidyselect_1.2.0        lattice_0.20-45        
 [7] R6_2.5.1                rlang_1.0.6             rnaturalearthdata_0.1.0
[10] fansi_1.0.4             dplyr_1.0.10            tools_4.2.2            
[13] grid_4.2.2              KernSmooth_2.23-20      utf8_1.2.2             
[16] cli_3.6.0               e1071_1.7-12            DBI_1.1.3              
[19] class_7.3-20            tibble_3.1.8            lifecycle_1.0.3        
[22] sf_1.0-9                vctrs_0.5.1             glue_1.6.2             
[25] sp_1.6-0                proxy_0.4-27            compiler_4.2.2         
[28] pillar_1.8.1            generics_0.1.3          classInt_0.4-8         
[31] pkgconfig_2.0.3   

@John-R-Wallace-NOAA Do you still have an issue?

John-R-Wallace-NOAA commented 1 year ago

After checking for updates, I still get the same issue under R 4.0.1 under CentOS (with gdal-2.4.1) on our Linux server. I also tried it under R 4.1.X, but the R package S2 (needed by the sf package) has an issue installing, perhaps needing some updated Linux libraries. I will ask IT to install R 4.2.X and go from there.

I just now got it to work running R 4.2.2 under Ubuntu 20.04.5 (with GDAL 3.3.2) on Windows Subsystem for Linux (WSL).

PMassicotte commented 1 year ago

Perfect, please let us know how it is going!