Open asinghvi17 opened 1 month ago
Also, holy shit, polygonize just works :O
zonal
works but polygonize
does not roundtrip through it, not sure what's going on there.
julia> using StatsBase; Rasters.zonal(countmap, grain; of = GO.polygonize(grain))
3-element Vector{Union{Missing, Dict{CategoricalValue{String, UInt32}, Int64}}}:
Dict{CategoricalValue{String, UInt32}, Int64}("sand" => 1, "clay" => 1)
Dict{CategoricalValue{String, UInt32}, Int64}("sand" => 1)
Dict{CategoricalValue{String, UInt32}, Int64}()
Aaaah I didn't realize DimensionalArrays has a CategoricalArrays extension! This makes much more sense now :D
Yeah maybe @tiemvanderdeure added that
What do you want write
to do. Write strings? Or an Integer?
Ok seems a UInt8 or UInt16 if there are more than 256 are what to do.
The dbf table trick is kinda weird but we could write one in a RastersCategoricalArraysExt extension, and have a categorical
keyword to force reading it?
Maybe netcdf can handle categories without that
Yes I added a small extensions that defines the basic operation of CategoricalArrays
on a DimArray
, which is why you can call categorical
and a Raster and it will behave. I never got round to making a similar extension for Rasters
though.
Another one to add to the list is to make missingval
make sense for categorical rasters - we probably need some dispatch of _convert_missingval
.
Right now, some in memory operations work with a Raster that wraps a CategoricalArray.
Here's an mwe:
This works fine, I'll update the issue to check if things like zonal work as intended.
.dbf
file (see https://gis.stackexchange.com/questions/404747/raster-categorical-attributes-not-showing-in-arcgis) so that the value is recognized as categorical, and https://desktop.arcgis.com/en/arcmap/latest/manage-data/raster-and-images/raster-dataset-attribute-tables.htmWriting does not work:
so maybe there need to be some more specific dispatches there.