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

typeof(missingval) should be a subtype of eltype #519

Closed
mauro3 opened this issue Sep 14, 2023 · 2 comments
Closed

typeof(missingval) should be a subtype of eltype #519

mauro3 opened this issue Sep 14, 2023 · 2 comments

Comments

@mauro3
Copy link
Collaborator

mauro3 commented Sep 14, 2023

Consider

ras = Raster(rand(Int32, X(25:1:30), Y(25:1:30)), missingval=-1.5)

Is allowing the type of missingval not being a subtype of the eltype useful for anything?

The reason I came across this is that it took me ages to figure out what was wrong here:

julia> ras = Raster(rand(Int32, X(25:1:30), Y(25:1:30)), missingval=-1)

6×6 Raster{Int32,2} with dimensions: 
  X Sampled{Int64} 25:1:30 ForwardOrdered Regular Points,
  Y Sampled{Int64} 25:1:30 ForwardOrdered Regular Points
extent: Extent(X = (25, 30), Y = (25, 30))
missingval: -1
parent:
              25           26           27           28          29           30
 25  -1577965140   -930532794  -1069034332  -1869000944  -876112444  -1896541373
 26  -2119450237   2112008256   -574130295    234237348   295379253  -1608673699
 27    479548452   1163904508  -1753155508   -779730610  -508137957   -545965278
 28   -518000084  -1234244315   2027127016  -1383270083  1182867062   1198615452
 29   -575807158    253215731    731658899  -1561393151  2005117126   1945068211
 30  -1836660204  -1824357014   -734002877    853304731  1129518778  -1924398571

julia> write("/tmp/band.tif", ras, force=true)
ERROR: GDALError (CE_Failure, code 1):
        GetNoDataValue() should be called instead

Stacktrace:
...

which can be fixed with

julia> ras = Raster(rand(Int32, X(25:1:30), Y(25:1:30)), missingval=Int32(-1));
julia> write("/tmp/band.tif", ras, force=true)

Anyways, should there be a conversion missingval = convert(eltyp(data), missingval)?

@rafaqz
Copy link
Owner

rafaqz commented Sep 14, 2023

Its probably not useful for anything.

And yes that could trigger the wrong gdal methods (it has specific methods for different types, which is kinda crazy)

Lets fix it to match the array eltype

@rafaqz
Copy link
Owner

rafaqz commented May 19, 2024

This is enforced now

@rafaqz rafaqz closed this as completed May 19, 2024
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

2 participants