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

Can't rasterize a GI.FeatureCollection #648

Closed
asinghvi17 opened this issue Apr 27, 2024 · 1 comment · Fixed by #651
Closed

Can't rasterize a GI.FeatureCollection #648

asinghvi17 opened this issue Apr 27, 2024 · 1 comment · Fixed by #651

Comments

@asinghvi17
Copy link
Contributor

MWE:

import GeoInterface as GI, GeometryOps as GO
using Rasters

p1 = GI.Polygon([[[-55965.680060140774, -31588.16072168928], [-55956.50771556479, -31478.09258677756], [-31577.548550575284, -6897.015828572996], [-15286.184961223798, -15386.952072224134], [-9074.387601621409, -27468.20712382156], [-8183.4538916097845, -31040.003969070774], [-27011.85123029944, -38229.02388009402], [-54954.72822634951, -32258.9734800704], [-55965.680060140774, -31588.16072168928]]])
p2 = GI.Polygon([[[-80000.0, -80000.0], [-80000.0, 80000.0], [-60000.0, 80000.0], [-50000.0, 40000.0], [-60000.0, -80000.0], [-80000.0, -80000.0]]])

fc = GI.FeatureCollection([GI.Feature(p1, properties = (;val=1)), GI.Feature(p2, properties = (;val=2))])

r1 = rasterize(fc; size = (1000, 1000), fill = :val)

Error:

ERROR: UndefKeywordError: keyword argument `name` not assigned
Stacktrace:
 [1] Rasters.Rasterizer(data::GeoInterface.Wrappers.FeatureCollection{…}; fill::Symbol, geomcolumn::Nothing, kw::@Kwargs{})
   @ Rasters ~/.julia/dev/Rasters/src/methods/rasterize.jl:171
 [2] rasterize(data::GeoInterface.Wrappers.FeatureCollection{…}; to::Nothing, fill::Symbol, threaded::Bool, kw::@Kwargs{})
   @ Rasters ~/.julia/dev/Rasters/src/methods/rasterize.jl:452
 [3] top-level scope
   @ ~/.julia/dev/AreaInterpolation/docs/src/tutorials/pycnophylactic.jl:173
Some type information was truncated. Use `show(err)` to see complete types.
@rafaqz
Copy link
Owner

rafaqz commented Apr 28, 2024

I'll PR the fix now. But FYI you always need to specify a reducing function to rasterize a collection

r1 = rasterize(sum, fc; size = (1000, 1000), fill = :val)

So we know what to do when two features overlap.

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

Successfully merging a pull request may close this issue.

2 participants