Giter VIP home page Giter VIP logo

Comments (8)

edzer avatar edzer commented on August 18, 2024 1

It's not about the age, but about how GDAL was built: linked against libnetcdf, or not. If not, the netcdf driver is missing and you get errors of this type.

from stars.

edzer avatar edzer commented on August 18, 2024 1

I could add a message at startup time of stars when the netcdf driver is missing.

from stars.

barracuda156 avatar barracuda156 commented on August 18, 2024

The same failure occurs with examples:

The error most likely occurred in:

> ### Name: mdim
> ### Title: Read or write data using GDAL's multidimensional array API
> ### Aliases: mdim read_mdim write_mdim
> 
> ### ** Examples
> 
> set.seed(135)
> m = matrix(runif(10), 2, 5)
> names(dim(m)) = c("stations", "time")
> times = as.Date("2022-05-01") + 1:5
> pts = st_as_sfc(c("POINT(0 1)", "POINT(3 5)"))
> s = st_as_stars(list(Precipitation = m)) |>
+  st_set_dimensions(1, values = pts) |>
+  st_set_dimensions(2, values = times)
> nc = tempfile(fileext=".nc")
> if (compareVersion(sf_extSoftVersion()["GDAL"], "3.4.0") > -1) {
+   write_mdim(s, nc)
+   # try ncdump on the generated file
+   print(read_mdim(nc))
+ }
Error: cannot open driver

from stars.

edzer avatar edzer commented on August 18, 2024

I'm seeing

Sys.setenv(TZ="")
library(stars)
# Loading required package: abind
# Loading required package: sf
# Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
m = matrix(1:4,2)
s = st_as_stars(m)
s = st_set_dimensions(s, st_dimensions(s), xy = NULL)
sfc = st_sfc(st_point(0:1), st_point(3:2))
s = st_set_dimensions(s, 1, sfc) |> st_set_crs(4326)
tm = as.POSIXct("2023-03-04 12:35") + c(0, 3600)
s = st_set_dimensions(s, 2, tm)
f = tempfile(fileext = ".nc")
write_mdim(s, f, as_float = FALSE)
# Warning messages:
# 1: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,  :
#   GDAL Error 6: SetIndexingVariable() not implemented
# 2: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,  :
#   GDAL Error 6: SetIndexingVariable() not implemented
read_mdim(f)
# stars object with 2 dimensions and 1 attribute
# attribute(s):
#     Min. 1st Qu. Median Mean 3rd Qu. Max.
# A1     1    1.75    2.5  2.5    3.25    4
# dimension(s):
#    from to                  offset   delta  refsys point
# X1    1  2                      NA      NA  WGS 84  TRUE
# X2    1  2 2023-03-04 12:35:00 UTC 1 hours POSIXct    NA
#                      values
# X1 POINT (0 1), POINT (3 2)
# X2                     NULL

Is this a GDAL version issue?

from stars.

barracuda156 avatar barracuda156 commented on August 18, 2024

@edzer Perhaps 3.9.0 is not too old? https://ports.macports.org/port/gdal

from stars.

barracuda156 avatar barracuda156 commented on August 18, 2024

@edzer I am building GDAL now with netcdf support enabled. Once confirmed tests pass then, I will close both issues as resolved.

P. S. Perhaps it is worth adding a note about this requirement though. Currently nothing is said about GDAL being linked to netcdf: https://cran.r-project.org/web/packages/stars/index.html
sf is also silent: https://cran.r-project.org/web/packages/sf/index.html
So how one is supposed to know it is necessary?

from stars.

barracuda156 avatar barracuda156 commented on August 18, 2024

I could add a message at startup time of stars when the netcdf driver is missing.

That will be helpful, I think.

from stars.

barracuda156 avatar barracuda156 commented on August 18, 2024

@edzer Files are now found, but specifically mdim example and test still fail for me, though differently:

* checking examples ...sh: line 1: 70105 Segmentation fault      LANGUAGE=en _R_CHECK_INTERNALS2_=1 '/opt/local/Library/Frameworks/R.framework/Resources/bin/R' --vanilla --encoding=UTF-8 > 'stars-Ex.Rout' 2>&1 < 'stars-Ex.R'
 ERROR
Running examples in ‘stars-Ex.R’ failed
The error most likely occurred in:

> ### Name: mdim
> ### Title: Read or write data using GDAL's multidimensional array API
> ### Aliases: mdim read_mdim write_mdim
> 
> ### ** Examples
> 
> set.seed(135)
> m = matrix(runif(10), 2, 5)
> names(dim(m)) = c("stations", "time")
> times = as.Date("2022-05-01") + 1:5
> pts = st_as_sfc(c("POINT(0 1)", "POINT(3 5)"))
> s = st_as_stars(list(Precipitation = m)) |>
+  st_set_dimensions(1, values = pts) |>
+  st_set_dimensions(2, values = times)
> nc = tempfile(fileext=".nc")
> if (compareVersion(sf_extSoftVersion()["GDAL"], "3.4.0") > -1) {
+   write_mdim(s, nc)
+   # try ncdump on the generated file
+   print(read_mdim(nc))
+ }
Warning in CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,  :
  GDAL Error 6: SetIndexingVariable() not implemented
Warning in CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,  :
  GDAL Error 6: SetIndexingVariable() not implemented

 *** caught segfault ***
address 0xc0000000, cause 'memory not mapped'

Traceback:
 1: CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,     options, as_float)
 2: gdal_write_mdim(filename, driver, c(dim(x), attr(cdl, "dims")),     cdl, wkt, xy, root_group_options = root_group_options, options = options,     as_float = as_float)
 3: write_mdim(s, nc)
An irrecoverable exception occurred. R is aborting now ...
  Running ‘mdim.R’/opt/local/Library/Frameworks/R.framework/Resources/bin/BATCH: line 60: 70383 Segmentation fault      ${R_HOME}/bin/R -f ${in} ${opts} ${R_BATCH_OPTIONS} > ${out} 2>&1

 ERROR
Running the tests in ‘tests/mdim.R’ failed.
Last 13 lines of output:
  > sfc = st_sfc(st_point(0:1), st_point(3:2))
  > s = st_set_dimensions(s, 1, sfc) |> st_set_crs(4326)
  > tm = as.POSIXct("2023-03-04 12:35") + c(0, 3600)
  > s = st_set_dimensions(s, 2, tm)
  > f = tempfile(fileext = ".nc")
  > write_mdim(s, f, as_float = FALSE)
  
   *** caught segfault ***
  address 0xc0000000, cause 'memory not mapped'
  
  Traceback:
   1: CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,     options, as_float)
   2: gdal_write_mdim(filename, driver, c(dim(x), attr(cdl, "dims")),     cdl, wkt, xy, root_group_options = root_group_options, options = options,     as_float = as_float)
   3: write_mdim(s, f, as_float = FALSE)
  An irrecoverable exception occurred. R is aborting now ...
* DONE

Status: 2 ERRORs, 1 WARNING, 2 NOTEs
See
  ‘/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_R_R-stars/R-stars/work/stars/stars.Rcheck/00check.log’
for details.

But it looks like it is using R BATCH, which is known to be broken for w/e reason: https://trac.macports.org/ticket/67059

All other tests now pass (with GDAL +netcdf).

from stars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.