Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasterize gives a confusing error when fill=:nonexistingcolumn #365

Closed
felixcremer opened this issue Jan 9, 2023 · 1 comment
Closed

Comments

@felixcremer
Copy link
Contributor

If I run rasterize with the fill keyword and give it a symbol of a :nonexistingcolumn I get the following confusing error.
Here shp is a Shapefile.Table and bbox is an Extent type.

julia> shpras = rasterize(shp; to=bbox, res=res, fill=:nonexistingcolumn)
ERROR: MethodError: zero(::Type{Union{}}) is ambiguous. Candidates:
  zero(::Union{Type{P}, P}) where P<:Dates.Period in Dates at /home/fcremer/.julia/juliaup/julia-1.8.4+0.x64.linux.gnu/share/julia/stdlib/v1.8/Dates/src/periods.jl:53
  zero(t::Union{Type{<:Zarr.DateTime64}, Zarr.DateTime64}) in Zarr at /home/fcremer/.julia/packages/Zarr/tmr2s/src/metadata.jl:47
  zero(::Type{<:AbstractIrrational}) in Base at irrationals.jl:151
  zero(::Type{C}) where C<:(ColorTypes.Colorant{T, 5} where T) in ColorTypes at /home/fcremer/.julia/packages/ColorTypes/1dGw6/src/traits.jl:476
  zero(::Type{C}) where C<:(ColorTypes.Colorant{T, 4} where T) in ColorTypes at /home/fcremer/.julia/packages/ColorTypes/1dGw6/src/traits.jl:475
  zero(::Type{C}) where C<:(ColorTypes.Colorant{T, 3} where T) in ColorTypes at /home/fcremer/.julia/packages/ColorTypes/1dGw6/src/traits.jl:474
  zero(::Type{C}) where C<:(ColorTypes.Colorant{T, 2} where T) in ColorTypes at /home/fcremer/.julia/packages/ColorTypes/1dGw6/src/traits.jl:473
  zero(::Type{C}) where C<:(ColorTypes.Colorant{T, 1} where T) in ColorTypes at /home/fcremer/.julia/packages/ColorTypes/1dGw6/src/traits.jl:472
  zero(::Type{X}) where X<:FixedPointNumbers.FixedPoint in FixedPointNumbers at /home/fcremer/.julia/packages/FixedPointNumbers/HAGk2/src/FixedPointNumbers.jl:107
  zero(::Type{T}) where T<:Number in Base at number.jl:297
  zero(::Type{<:ChainRulesCore.NotImplemented}) in ChainRulesCore at /home/fcremer/.julia/packages/ChainRulesCore/C73ay/src/tangent_types/notimplemented.jl:52
  zero(::Type{<:ChainRulesCore.AbstractTangent}) in ChainRulesCore at /home/fcremer/.julia/packages/ChainRulesCore/C73ay/src/tangent_types/abstract_zero.jl:58
  zero(a::Type{SA}) where SA<:StaticArraysCore.StaticArray in StaticArrays at /home/fcremer/.julia/packages/StaticArrays/jA1zK/src/linalg.jl:96
Possible fix, define
  zero(::Type{Union{}})
Stacktrace:
 [1] _rasterize(to::Tuple{X{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Rasters.AutoDim}}, Y{Projected{Float64, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, DimensionalData.Dimensions.LookupArrays.ForwardOrdered, DimensionalData.Dimensions.LookupArrays.Regular{Float64}, DimensionalData.Dimensions.LookupArrays.Intervals{DimensionalData.Dimensions.LookupArrays.Start}, DimensionalData.Dimensions.LookupArrays.NoMetadata, Nothing, Nothing, Rasters.AutoDim}}}, ::Nothing, data::Shapefile.Table{Union{Missing, Shapefile.Polygon}}; fill::Symbol, name::Symbol, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Rasters ~/.julia/packages/Rasters/gV0im/src/methods/rasterize.jl:119
 [2] #_rasterize#507
   @ ~/.julia/packages/Rasters/gV0im/src/methods/rasterize.jl:90 [inlined]
 [3] _rasterize(to::Extent{(:X, :Y), Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}}}, data::Shapefile.Table{Union{Missing, Shapefile.Polygon}}; fill::Symbol, name::Symbol, res::Float64, size::Nothing, kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Rasters ~/.julia/packages/Rasters/gV0im/src/methods/rasterize.jl:87
 [4] #rasterize#502
   @ ~/.julia/packages/Rasters/gV0im/src/methods/rasterize.jl:66 [inlined]
 [5] top-level scope
   @ REPL[35]:1
@rafaqz
Copy link
Owner

rafaqz commented Apr 16, 2023

The error is now:

ERROR: ArgumentError: fill key nonexistingcolumn not found in table, use one of: (:geometry, :val1, :val2)

@rafaqz rafaqz closed this as completed Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants