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

IO not exported? #145

Closed
gottacatchenall opened this issue Feb 16, 2023 · 5 comments · Fixed by #146
Closed

IO not exported? #145

gottacatchenall opened this issue Feb 16, 2023 · 5 comments · Fixed by #146

Comments

@gottacatchenall
Copy link
Member

gottacatchenall commented Feb 16, 2023

Am I missing a new change to the API or are the files in ./src/io not exported? Is there another way to read/write from disk?

@gottacatchenall gottacatchenall changed the title IO not included/exported? IO not exported? Feb 16, 2023
@tpoisot
Copy link
Member

tpoisot commented Feb 16, 2023

They are loaded but not exported:

# Functions for IO
include("io/geotiff.jl")
include("io/ascii.jl")
include("io/read_write.jl")

You can read manually with:

function _read_geotiff(

But you can also look at the way data from SimpleSDMDatasets are loaded, e.g.:

function SimpleSDMLayers.SimpleSDMPredictor(data::R; kwargs...) where {R <: RasterData}

This might need a documentation mention when I port all of the docstrings to the website.

@tpoisot
Copy link
Member

tpoisot commented Feb 16, 2023

(also the reason not to export it is: I like it when other packages don't export the IO functions because it's a less important part of the process)

@gottacatchenall
Copy link
Member Author

gottacatchenall commented Feb 16, 2023

Ah okay I found the save method call but currently am getting an error trying to write a demo CHELSA layer with

bbox = (left=1.,right=2.,bottom=1.,top=2.)
a = convert(Float32, SimpleSDMPredictor(RasterData(CHELSA2, BioClim); layer=1, bbox...)))
SpeciesDistributionToolkit.save("tmp.tif", a)

which yields ERROR: AssertionError: eltype(layer) <: Number.

In practice I can probably get around this by not using similar(example_chelsa_layer) (although its less verbose than including a boundingbox call to retain the same coords when using the SimpleSDMPredictor constructor directly) calls to allocate memory, but is there a reason to not include a method to convert from the RasterData inner type as constructed above to be a SimpleSDMPredictor{T} where T<:Number for this case?

@tpoisot
Copy link
Member

tpoisot commented Feb 16, 2023

Yup that is indeed a likely bug, let me see.

@tpoisot
Copy link
Member

tpoisot commented Feb 16, 2023

OK I have opened a PR (#146) with a fix. The eltype has changed to facilitate the Tables/iteration interface, so there's an unexported function called _inner_type that does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants