Circuitscape / Omniscape.jl

Functions to compute omnidirectional landscape connectivity using circuit theory and the Omniscape algorithm.
https://docs.circuitscape.org/Omniscape.jl/stable/
MIT License
58 stars 12 forks source link

Error in writing final outputs - no method matching setgeotransform #156

Open gagecarto opened 8 months ago

gagecarto commented 8 months ago

I am getting started with the new version of Omniscape and having some issues where no output files are written once everything finishes. The dataset I am using for resistance is in EPSG:4326 - WGS 84. The same configuration and input used to work when I was using Omniscape 0.5.3

The error message I receive at the end is listed below

 @ Omniscape ~/.julia/packages/Omniscape/VSLPS/src/main.jl:155
[ Info: Starting up Omniscape with 25 workers and double precision
[ Info: Using Circuitscape with the cg+amg solver...
[ Info: Calculating block artifact correction array...
[ Info: Solving moving window targets...
Progress: 100%|██████████████████████████████████████████████████| Time: 0:10:15
ERROR: MethodError: no method matching setgeotransform!(::ArchGDAL.Dataset, ::Nothing)

Closest candidates are:
  setgeotransform!(::T, ::Vector{Float64}) where T<:ArchGDAL.AbstractDataset
   @ ArchGDAL ~/.julia/packages/ArchGDAL/lgE4A/src/dataset.jl:934

Stacktrace:
 [1] (::Omniscape.var"#3#4"{String, Nothing, String, Matrix{Float64}})(dataset::ArchGDAL.Dataset)
   @ Omniscape ~/.julia/packages/Omniscape/VSLPS/src/io.jl:94
 [2] create(f::Omniscape.var"#3#4"{…}, args::String; kwargs::@Kwargs{…})
   @ ArchGDAL ~/.julia/packages/ArchGDAL/lgE4A/src/context.jl:268
 [3] write_raster(fn_prefix::String, array::Matrix{Float64}, wkt::String, transform::Nothing, file_format::String)
   @ Omniscape ~/.julia/packages/Omniscape/VSLPS/src/io.jl:81
 [4] run_omniscape(cfg::Dict{…}, resistance::Matrix{…}; reclass_table::Nothing, source_strength::Matrix{…}, condition1::Nothing, condition2::Nothing, condition1_future::Nothing, condition2_future::Nothing, wkt::String, geotransform::Nothing, write_outputs::Bool)
   @ Omniscape ~/.julia/packages/Omniscape/VSLPS/src/main.jl:371
 [5] top-level scope
   @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

The script I use to run looks like this

resistance, wkt, transform = Omniscape.read_raster("data/resistancesnap.tif", Float64)
config = Dict{String, String}(
    "radius" => "37",
    "block_size" => "3",    
    "project_name" => "outputfolder",
    "source_from_resistance" => "true",        
    "calc_normalized_current" => "true",
    "calc_flow_potential" => "true",
    "write_raw_currmap" => "true",
    "mask_nodata" => "true",
    "parallelize" => "true",
    "parallel_batch_size" => "15"
)
run_omniscape(config,resistance,wkt=wkt,write_outputs = true)
vlandau commented 8 months ago

Was this exact same problem working in a previous environment (including outputs being successfully written)? What is your version of ArchGDAL? I wonder if there was a breaking change there.

gagecarto commented 8 months ago

I ran

Pkg.status() 

to get installed packages. It only returns

Status `~/.julia/environments/v1.10/Project.toml`
  [a38d70fc] Omniscape v0.6.2

I then did

(@v1.10) pkg> add ArchGDAL

 Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
    Updating `~/.julia/environments/v1.10/Project.toml`
  [c9ce4bd3] + ArchGDAL v0.10.2
  No Changes to `~/.julia/environments/v1.10/Manifest.toml`

Finally I tested ArchGDAL and some errors were returned

(@v1.10) pkg> test ArchGDAL
Test Summary:                                  | Pass  Error  Total     Time
ArchGDAL                                       | 1895      1   1896  1m35.1s
  Doctests: ArchGDAL                           |    1             1     3.8s
  test_convert.jl                              |   34            34     0.6s
  test_tables.jl                               |   66            66     9.6s
  test_gdal_tutorials.jl                       |   46            46     3.1s
  test_geometry.jl                             |  260           260     9.8s
  test_types.jl                                |  115           115     0.2s
  test_display.jl                              |   19            19     0.9s
  test_drivers.jl                              |   37            37     0.6s
  test_feature.jl                              |  197           197     2.6s
  test_featurelayer.jl                         |   66            66     1.5s
  test_fielddefn.jl                            |   94            94     1.1s
  test_iterators.jl                            |    6             6     0.1s
  test_styletable.jl                           |   34            34     0.5s
  test_dataset.jl                              |   86            86    17.4s
  test_rasterband.jl                           |   38            38     0.9s
  test_rasterio.jl                             |   41            41     9.5s
  Complex IO                                   |    2             2     1.1s
  test_array.jl                                |   57            57     9.7s
  test_spatialref.jl                           |   33      1     34     1.9s
    Test Formats for Spatial Reference Systems |   25      1     26     1.8s
      PROJ4 Format                             |    3             3     0.1s
      WKT Format                               |    3             3     0.0s
      ESRI Format                              |    3             3     0.1s
      XML Format                               |    3             3     0.1s
      User provided Format                     |    3             3     0.1s
      URL Import                               |           1      1     1.3s
      generic importCRS                        |   10            10     0.1s
    Cloning NULL SRS                           |    2             2     0.0s
    Getting and Setting Attribute Values       |    6             6     0.1s
  test_gdalutilities.jl                        |   20            20     1.2s
  Interactive data/utmsmall.tif                |   17            17     0.2s
  test_gdalutilities_errors.jl                 |   12            12     0.1s
  test_rasterattrtable.jl                      |   57            57     0.9s
  test_ospy_examples.jl                        |  273           273     3.5s
  test_geos_operations.jl                      |   91            91     2.3s
  test_cookbook_geometry.jl                    |   82            82     2.0s
  test_cookbook_projection.jl                  |   34            34     1.4s
  test_geotransform.jl                         |    8             8     0.0s
  test_images.jl                               |   41            41     2.2s
  test_utils.jl                                |   23            23     0.0s
  Prepared Geometry                            |    5             5     0.1s
ERROR: LoadError: Some tests did not pass: 1895 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /home/ec2-user/.julia/packages/ArchGDAL/lgE4A/test/runtests.jl:8
ERROR: Package ArchGDAL errored during testing
vlandau commented 8 months ago

I think you might just need to specify a transform, or for some reason, it's not getting picked up. I'll look into this. Was the same exact code working before you updated Omniscape?

gagecarto commented 8 months ago

Yes.. The same code was working before the update

vlandau commented 8 months ago

Okay good to know. I'll try to check this out this evening.

vlandau commented 7 months ago

Haven't yet been able to take a look. Things have been crazy busy the past few days. I'll try to take a look this weekend.