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

get_targets returns block coordinates outside of array dims. #37

Closed vlandau closed 4 years ago

vlandau commented 4 years ago
ERROR: TaskFailedException:
BoundsError: attempt to access 182×335 Array{Float64,2} at index [148:188, 148:188]
Stacktrace:
 [1] throw_boundserror(::Array{Float64,2}, ::Tuple{UnitRange{Int64},UnitRange{Int64}}) at ./abstractarray.jl:537
 [2] checkbounds at ./abstractarray.jl:502 [inlined]
 [3] view at ./subarray.jl:163 [inlined]
 [4] maybeview at ./views.jl:124 [inlined]
 [5] dotview at ./broadcast.jl:1138 [inlined]
 [6] get_source(::Array{Float64,2}, ::Dict{String,Int64}, ::Bool, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}, ::String, ::String, ::Float64, ::Float64, ::Float64, ::Float64; x::Int64, y::Int64, strength::Float64) at /root/.julia/packages/Omniscape/IVo2x/src/functions.jl:161
 [7] solve_target!(::Int64, ::Int64, ::Dict{String,Int64}, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}, ::Dict{String,String}, ::Circuitscape.OutputFlags, ::Bool, ::Bool, ::Bool, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,2}, ::String, ::String, ::Float64, ::Float64, ::Float64, ::Float64, ::Array{Float64,2}, ::Array{Float64,3}, ::Array{Float64,3}) at /root/.julia/packages/Omniscape/IVo2x/src/functions.jl:445
 [8] macro expansion at /root/.julia/packages/Omniscape/IVo2x/src/run_omniscape.jl:270 [inlined]
 [9] (::Omniscape.var"#45#threadsfor_fun#11"{Dict{String,Int64},Bool,Bool,Bool,Array{Float64,2},String,String,Float64,Float64,Float64,Float64,Dict{String,String},Array{Float64,2},Int64,Circuitscape.OutputFlags,Int64,UnitRange{Int64}})(::Bool) at ./threadingconstructs.jl:61
 [10] (::Omniscape.var"#45#threadsfor_fun#11"{Dict{String,Int64},Bool,Bool,Bool,Array{Float64,2},String,String,Float64,Float64,Float64,Float64,Dict{String,String},Array{Float64,2},Int64,Circuitscape.OutputFlags,Int64,UnitRange{Int64}})() at ./threadingconstructs.jl:28
Stacktrace:
 [1] wait(::Task) at ./task.jl:267
 [2] macro expansion at ./threadingconstructs.jl:69 [inlined]
 [3] run_omniscape(::String) at /root/.julia/packages/Omniscape/IVo2x/src/run_omniscape.jl:265
 [4] top-level scope at none:1

Omniscape settings/conditions that gave rise to this: block_size = 41 radius = 167 buffer = 0 Source array dims: 18280x14496

So y was < 41 pixels from array edge, which shouldn't happen. This appears to be an issue with get_targets returning blocks that are not fully within the source array. The minimum number of rows (or columns) in a returned source should be radius + 1 + (0.5 * (block_size - 1)). In this case that's equal to 167 + 1 + 20 = 188.

ekbuchholtz commented 4 years ago

When solving targets, I get the following error: ERROR: BoundsError: attempt to access 568×742 Array{Float64,2} at index [489:569, 1:41]

My input ascii file is 568x742, and I'm using radius = 40, block_size = 1, buffer = 0 I have tried a variety of block sizes and radii to get them to fit, but no luck yet getting it to solve without the BoundsError.

Is there a way to figure out which combinations of blocks/radius will work or not, depending on the number of source cells? Do I need to crop my input files to better dimensions? I can also attach the ini and input files if that will help.

Using julia 1.0.5

vlandau commented 4 years ago

Can you run using Pkg; Pkg.status("Omniscape") and post the output? Omniscape v0.2 requires Julia 1.4 or greater.

ekbuchholtz commented 4 years ago

Ok, that might be the issue that I'm in an older Julia version. I haven't been able to get Julia 1.4.2 and GDAL and ArchGDAL to play well together yet so I was just trying to use Omniscape with the older Julia version.

julia> using Pkg; Pkg.status("Omniscape") ERROR: MethodError: no method matching status(::Pkg.Types.Context, ::String)

vlandau commented 4 years ago

Are you on Windows by chance? If so see #47 -- wondering if you might be having similar issues to the user who posted (and solved!) it.

vlandau commented 4 years ago

using Pkg; Pkg.status("Omniscape")

I'm not sure why this didn't work -- maybe something to do with the Julia version.

ekbuchholtz commented 4 years ago

Are you on Windows by chance? If so see #47 -- wondering if you might be having similar issues to the user who posted (and solved!) it.

Yes, on Windows. At first thought it was an administrator-type problem on my work computer, but #47 solved it. Haven't gotten the Bounds error now with the updated Julia version. Thanks!

vlandau commented 4 years ago

Awesome!! Glad you figured it out. I will add appending a note to the README/docs about GDAL issues to the to do list.