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

GdalType as Pulic #48

Closed
austinstig opened this issue Jan 28, 2018 · 9 comments · Fixed by #66
Closed

GdalType as Pulic #48

austinstig opened this issue Jan 28, 2018 · 9 comments · Fixed by #66

Comments

@austinstig
Copy link

I would like to be able to write a function that loads a raster dataset into an ndarray. For instance:
fn read_as_array<T: Copy + From<GdalType>, P: AsRef<Path>>(path: P) -> Result<ndarray::Array2<T>> { ... }

This would internally coerce the GdalType values into their corresponding primitive number type. Unfortunately, GdalType is currently marked private and this is not possible. Would it be possible to mark it as pub or am I approaching this problem incorrectly?

@jdroenner
Copy link
Member

I'm not really sure if we want GdalType to be public. Let me think about the implications :)

@jdroenner
Copy link
Member

Since Array2 is the obvious data-structure for raster data, i guess we should add such method directly to rust-gdal. However, we should use a feature "ndarray" to allow disabling.

Do you think this would work for your use-case?

@austinstig
Copy link
Author

yes... that would be really great!

@jdroenner
Copy link
Member

Great :) If you already have a matching method feel free to create a pull request. Otherwise i will see if i have time to write something :)

@austinstig
Copy link
Author

No problem. I'll work on it.

@austinstig
Copy link
Author

Not sure how great it is but I have submitted PR. Thanks!

@jdroenner
Copy link
Member

Great! thank you :) I will look at it as soon as possible (when i have some free time).

@njwilson23
Copy link
Contributor

I have another use case that I think would benefit from GdalType being public. I'm trying to write a function that, given a sequence of bands, combines them into a dataset.

Since the GDAL data type isn't part of the RasterBand type, I think I need to hard-code the band type in the caller. I think the signature might look something like

fn combine<T: GdalType>(b1: &RasterBand, b2: &RasterBand, ...) -> Result<Dataset, Error>

Is there an alternative that I should consider?

@jdroenner
Copy link
Member

Since the GdalDatatatype in gdal-sys is pub, GdalType can probably also be pub. Do you want to create a pull request?

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.

3 participants