-
Notifications
You must be signed in to change notification settings - Fork 37
WIP: support attribute tables #987
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally I've just implemented _tablemod
like this
function Rasters._tablemod(filename, missingval, name::Rasters.NoKW)
table = Tables.columntable(DBFTables.Table(filename))
idx = findfirst(k -> k !== :VALUE && k !== :COUNT && k !== :Value && k !== :Count, keys(table))
name = keys(table)[idx]
return Rasters.AttributeMod(table, name, missingval)
end
function Rasters._tablemod(filename, missingval, name::Symbol)
table = Tables.columntable(DBFTables.Table(filename))
return Rasters.AttributeMod(table, name, missingval)
end
This works at least for the example I posted in #921
Looks great! |
# Generate mod for scaling | ||
mod = isnokw(mod) ? _mod(eltype(var), metadata_out, missingval_out; scaled, coerce) : mod | ||
mod = if isnokw(mod) | ||
if !raw && isfile(filename .* ".vat.dbf") # todo: how to detect a RAT/VAT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this be able to pick up ArchGDAL rats. Maybe that goes in the extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because those have .tif.rat or something which is a different format...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I have to think about how to check for all of that. I'm not sure if there are more formats than just those two? And if different file extensions than .tif could have a RAT or something similar?
function AttributeMod(table::NamedTuple, column::Symbol, missingval::Mi) where {Mi} | ||
keycol = identity.(first(table)) | ||
valcol = identity.(table[column]) | ||
dict = DD.OrderedCollections.LittleDict(keycol, valcol) |> DD.OrderedCollections.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Implements a new modification for raster attribute tables. In this standard, the .tif contains integers which correspond to a row in an attribute table.
It's a pretty obscure standard. One example I've seen have integer values 0,1,2,3, and the other has 0, 12,13,14 for some reason. One has a column called VALUE and the other Value.
The idea here is to store a dict in a AbstractModifications and then just perform a lookup within readblock!
GDAL reads some of these tables but not all and then can have different file extension names, so
_tablemod
I still need to implement