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

Too hard to create a raster with a run-time data type #483

Open
Tracked by #484
lnicola opened this issue Dec 2, 2023 · 4 comments
Open
Tracked by #484

Too hard to create a raster with a run-time data type #483

lnicola opened this issue Dec 2, 2023 · 4 comments

Comments

@lnicola
Copy link
Member

lnicola commented Dec 2, 2023

Driver::create_with_band_type_with_options takes the type as a generic parameter, which is pretty annoying.

@lnicola lnicola mentioned this issue Dec 2, 2023
8 tasks
@jdroenner
Copy link
Member

i guess that depends how you use it. I usually want to read data with the type of the dataset and when creating a dataset i want that to have the type of the data. In both cases it is nice to use the same generic T for rasterio and driver/band creation.
I guess we can also add another method where the type is provided as a parameter.

@metasim
Copy link
Contributor

metasim commented Dec 6, 2023

I find this super frustrating also. As a point of comparison, I have this sort of thing all over my code:

match &raster.cell_type {
    CellType::UInt8 => write_dataset(&raster.data.cast_as::<u8>(), &raster.mask, self),
    CellType::UInt16 => write_dataset(&raster.data.cast_as::<u16>(), &raster.mask, self),
    CellType::UInt32 => write_dataset(&raster.data.cast_as::<u32>(), &raster.mask, self),
    CellType::Int16 => write_dataset(&raster.data.cast_as::<i16>(), &raster.mask, self),
    CellType::Int32 => write_dataset(&raster.data.cast_as::<i32>(), &raster.mask, self),
    CellType::Float32 => write_dataset(&raster.data.cast_as::<f32>(), &raster.mask, self),
    CellType::Float64 => write_dataset(&raster.data.cast_as::<f64>(), &raster.mask, self),
}

As an antidote, i've been working on a side project called erased-cells to allow for compile-time-deferred celltype handling. No GDAL connector yet, but will currently have to gdal_sys directly to get everything I need. :(

@lnicola
Copy link
Member Author

lnicola commented Dec 6, 2023

I just realized it's create_with_band_type_with_options and not create_with_band_type_and_options 😅.

Time for a create_with_explicit_band_type_with_options? 😄

@metasim
Copy link
Contributor

metasim commented Dec 6, 2023

ooof 🤢

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

No branches or pull requests

3 participants