Skip to content

crop with Shapefile.Row fails #944

@felixcremer

Description

@felixcremer

Trying to crop a Raster with a Shapefile.Table works, but when I select a single row from that Table it fails with the following error:

julia> crop(s1_cube_asc, to=farm)
ERROR: MethodError: no method matching length(::Shapefile.Row{Shapefile.Polygon})
The function `length` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  length(::DataStructures.SparseIntSet)
   @ DataStructures ~/.julia/packages/DataStructures/IrAJn/src/sparse_int_set.jl:61
  length(::Markdown.MD)
   @ Markdown ~/.julia/juliaup/julia-1.11.4+0.x64.linux.gnu/share/julia/stdlib/v1.11/Markdown/src/parse/parse.jl:37
  length(::Distributions.DirichletStats)
   @ Distributions ~/.julia/packages/Distributions/qRkAO/src/multivariate/dirichlet.jl:186
  ...

Stacktrace:
 [1] _similar_shape(itr::Shapefile.Row{Shapefile.Polygon}, ::Base.HasLength)
   @ Base ./array.jl:663
 [2] _collect(cont::UnitRange{Int64}, itr::Shapefile.Row{Shapefile.Polygon}, ::Base.HasEltype, isz::Base.HasLength)
   @ Base ./array.jl:722
 [3] collect(itr::Shapefile.Row{Shapefile.Polygon})
   @ Base ./array.jl:716
 [4] _get_geometries(data::Shapefile.Row{Shapefile.Polygon}, ::Nothing)
   @ Rasters ~/.julia/packages/Rasters/UTSRc/src/utils.jl:259
 [5] _extent(data::Shapefile.Row{Shapefile.Polygon}; geometrycolumn::Nothing, kw::@Kwargs{})
   @ Rasters ~/.julia/packages/Rasters/UTSRc/src/methods/burning/extents.jl:5
 [6] _crop_to(x::Raster{…}, to::Shapefile.Row{…}; geometrycolumn::Nothing, kw::@Kwargs{})
   @ Rasters ~/.julia/packages/Rasters/UTSRc/src/methods/crop_extend.jl:87
 [7] _crop_to(x::Raster{…}, to::Shapefile.Row{…})
   @ Rasters ~/.julia/packages/Rasters/UTSRc/src/methods/crop_extend.jl:86
 [8] crop(x::Raster{…}; to::Shapefile.Row{…}, kw::@Kwargs{})
   @ Rasters ~/.julia/packages/Rasters/UTSRc/src/methods/crop_extend.jl:83
 [9] top-level scope
   @ REPL[55]:1
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions