Circuitscape / Circuitscape.jl

Algorithms from circuit theory to predict connectivity in heterogeneous landscapes
https://circuitscape.org
MIT License
128 stars 35 forks source link

BoundsError #287

Closed Peterak100 closed 3 years ago

Peterak100 commented 3 years ago

Hi, I'm trying to get the Julia version of Circuitscape running successfully. I've installed the program and it passed the tests, however when I try to run a test example with a small resistance layer (178 x 267 pixels), I'm getting the following error:

julia> compute("PK-julia2-test.ini") [ Info: 2021-04-23 16:43:44 : Precision used: Double [ Info: 2021-04-23 16:43:49 : Reading maps [ Info: 2021-04-23 16:43:50 : Resistance/Conductance map has 46702 nodes ERROR: BoundsError: attempt to access 23352-element Vector{Int64} at index [23354] Stacktrace: [1] _deleteat! @ .\array.jl:895 [inlined] [2] deleteat!(a::Vector{Int64}, i::Int64) @ Base .\array.jl:1339 [3] read_point_map(V::Type, file::String, habitatmeta::Circuitscape.RasterMeta) @ Circuitscape ~.julia\packages\Circuitscape\9x9VD\src\io.jl:203 [4] load_raster_data(T::Type, V::Type, cfg::Dict{String, String}) @ Circuitscape ~.julia\packages\Circuitscape\9x9VD\src\io.jl:415 [5] raster_pairwise(T::Type, V::Type, cfg::Dict{String, String}) @ Circuitscape ~.julia\packages\Circuitscape\9x9VD\src\raster\pairwise.jl:18 [6] _compute(T::Type, V::Type, cfg::Dict{String, String}) @ Circuitscape ~.julia\packages\Circuitscape\9x9VD\src\run.jl:42 [7] macro expansion @ .\timing.jl:287 [inlined] [8] compute(path::String) @ Circuitscape ~.julia\packages\Circuitscape\9x9VD\src\run.jl:31 [9] top-level scope @ REPL[6]:1

My INI file, resistance and patches layer files are in the attached zip file (SBV_crop2r is the resistance layer). This runs successfully with Circuitscape 4.

I saw that for a previous 'BoundsError' issue you recommended running the following:

Pkg.add(PackageSpec(name="Circuitscape", rev = "master"))

I tried that but this gave the following:

ERROR: UndefVarError: Pkg not defined Stacktrace: [1] top-level scope @ REPL[2]:1

PK-julia2-test.zip

rafaqz commented 3 years ago

Turns out this is caused by errors in the source files nodata values not matching the data. It might be nice to give a clearer error than the bounds error when the lengths differ, as it's pretty opaque.

While fixing the files works on v5.7.1, how ArchGDAL is versioned makes Pkg choose Circuitscape 5.5.5 for me, on which there is still a bounds error after fixing this, for some other reason!! Pretty confusing ;)