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 fails when passed single geometry and to=dims(raster) #819

Open
asinghvi17 opened this issue Nov 12, 2024 · 2 comments
Open

rasterize fails when passed single geometry and to=dims(raster) #819

asinghvi17 opened this issue Nov 12, 2024 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@asinghvi17
Copy link
Collaborator

MWE:

using Rasters, GeoInterface
geom = GeoInterface.Polygon([GeoInterface.LinearRing([(0.0, 0.0), (0.0, 10.0), (10.0, 10.0), (10.0, 0.0), (0.0, 0.0)])])
raster = Raster(ones(11, 11), (X(1:0.1:2), Y(1:0.1:2)))

rasterize(geom; to = raster, fill = 1, geometrycolumn = nothing) # works
rasterize(geom; to = dims(raster), fill = 1, geometrycolumn = nothing) # errors

Error message:

ERROR: UndefKeywordError: keyword argument `geometrycolumn` not assigned
Stacktrace:
 [1] _extent(::Nothing, data::Tuple{X{…}, Y{…}})
   @ Rasters ~/.julia/dev/Rasters/src/methods/burning/extents.jl:5
 [2] _extent(geom::Tuple{X{…}, Y{…}}; kw::@Kwargs{})
   @ Rasters ~/.julia/dev/Rasters/src/methods/burning/extents.jl:4
 [3] Rasters.RasterCreator(to::Tuple{…}, data::GeoInterface.Wrappers.Polygon{…}; kw::@Kwargs{})
   @ Rasters ~/.julia/dev/Rasters/src/methods/rasterize.jl:72
 [4] rasterize(data::GeoInterface.Wrappers.Polygon{…}; to::Tuple{…}, fill::Int64, threaded::Bool, geometrycolumn::Nothing, kw::@Kwargs{})
   @ Rasters ~/.julia/dev/Rasters/src/methods/rasterize.jl:430
 [5] top-level scope
   @ Untitled-6:8
Some type information was truncated. Use `show(err)` to see complete types.
@asinghvi17 asinghvi17 added the bug Something isn't working label Nov 12, 2024
@asinghvi17
Copy link
Collaborator Author

Looks like it's calling _extent on the dims. Maybe there should be a dispatch for that...

@asinghvi17
Copy link
Collaborator Author

asinghvi17 commented Nov 12, 2024

looks like we just need a dispatch

_extent(::Nothing, data::NTuple{N, <: Dimension}; kw...)::XYExtent where N = _float64_xy_extent(Extents.extent(data))

if someone wants to PR and add a test! It's in src/methods/burning/extents.jl, line 20.

@asinghvi17 asinghvi17 added the good first issue Good for newcomers label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant