WIP: support attribute tables#987
Draft
tiemvanderdeure wants to merge 2 commits into
Draft
Conversation
tiemvanderdeure
commented
Jun 27, 2025
tiemvanderdeure
left a comment
Collaborator
Author
There was a problem hiding this comment.
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
Owner
|
Looks great! |
asinghvi17
reviewed
Jun 27, 2025
| # 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? |
Collaborator
There was a problem hiding this comment.
We should make this be able to pick up ArchGDAL rats. Maybe that goes in the extension?
Collaborator
There was a problem hiding this comment.
Because those have .tif.rat or something which is a different format...
Collaborator
Author
There was a problem hiding this comment.
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?
asinghvi17
approved these changes
Jun 27, 2025
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
_tablemodI still need to implement