MethodError using Omniscape

Hi all,

I’m working on running an analysis in Omniscape, and am battling an error that I will post below. I have run these analyses before without issue. I’m getting this issue even when trying files that worked successfully a few months ago, and on different computers. The resistance, source layers, and .ini file looks fine.

Any help is very much appreciated!

julia> run_omniscape(“chase_config.ini”)
┌ Warning: Your specified project directory, outputs/chase_local_movement, already exists. Writing outputs to outputs/chase_local_movement_2.
└ @ Omniscape C:\Users\peteb.julia\packages\Omniscape\VSLPS\src\main.jl:155
[ Info: Starting up Omniscape with 8 workers and double precision
[ Info: Using Circuitscape with the cg+amg solver…
[ Info: Calculating block artifact correction array…
ERROR: MethodError: no method matching missingarray_to_array(::Matrix{Union{Missing, Float64}}, ::Int64)
This error has been manually thrown, explicitly, so the method may exist but be intentionally marked as unimplemented.

Closest candidates are:
missingarray_to_array(::Array{Union{Missing, T}, N} where {N, T<:Number}, ::Number)
@ Omniscape C:\Users\peteb.julia\packages\Omniscape\VSLPS\src\utils.jl:614

Stacktrace:
[1] calc_correction(arguments::Dict{…}, os_flags::Omniscape.OmniscapeFlags, cs_cfg::Dict{…}, condition_layers::Omniscape.ConditionLayers{…}, conditions::Omniscape.Conditions, precision::DataType)
@ Omniscape C:\Users\peteb.julia\packages\Omniscape\VSLPS\src\utils.jl:471
[2] 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::Vector{…}, write_outputs::Bool)
@ Omniscape C:\Users\peteb.julia\packages\Omniscape\VSLPS\src\main.jl:252
[3] run_omniscape(path::String)
@ Omniscape C:\Users\peteb.julia\packages\Omniscape\VSLPS\src\main.jl:558
[4] top-level scope
@ REPL[12]:1
Some type information was truncated. Use show(err) to see complete types.

Odd, that call signature looks like it would dispatch to that method, can you check that file and line for what the method body is?

Hi Benny,

Sorry I don’t totally know what you mean by that. But here is the .ini file that I’m getting the error on (this just worked perfectly a month ago) if this helps.

[Input files]
resistance_file=resistance_map.tif

[Options]
project_name=outputs/chase_local_movement
block_size=13
radius=313
source_from_resistance=true
write_raw_currmap=true
calc_normalized_current=true
calc_flow_potential=true
mask_nodata=true
write_as_tif=true
parallelize=true

Ah never mind, here is the code from that file at line 614 onwards

*nodata**: The numeric value with which missing values will be replaced in
the result.
“”"
function missingarray_to_array(
A::MissingArray{T, N} where T <: Number where N,
nodata::Number
)
output = copy(A)
output[ismissing.(output)] .= nodata

return convert(Array{typeof(output[1]), ndims(output)}, output)

By all appearances of the stacktrace, that method dispatch should have worked, and that method works on simple inputs when copied and isolated to a different module. There’s an open issue for this, so if you have a Github account you could chime in there as another user. That issue’s commenters say that downgrading to Julia 1.11 works in the meantime, though I can’t imagine how 1.12 made a difference.

method dispatch error when running forest connectivity example · Issue #160 · Circuitscape/Omniscape.jl

Just curious, does this run properly for you on 1.12?

module Blah
const MissingArray{T, N} = Array{Union{Missing, T}, N}
function missingarray_to_array(
        A::MissingArray{T, N} where T <: Number where N,
        nodata::Number
    )
    output = copy(A)
    output[ismissing.(output)] .= nodata

    return convert(Array{typeof(output[1]), ndims(output)}, output)
end
end

Blah.missingarray_to_array([0.1 missing                                                                                                                                                                
                            2.3 missing], -9999)

import Omniscape

Omniscape.missingarray_to_array([0.1 missing                                                                                                                                                                
                                 2.3 missing], -9999)