Skip to content

Commit

Permalink
Fix nodata not being set on GeoArray without any Missing values.
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Jun 20, 2022
1 parent 9d210e1 commit 1bd263a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GeoArrays"
uuid = "2fb1d81b-e6a0-5fc5-82e6-8e06903437ab"
authors = ["Maarten Pronk <[email protected]>"]
version = "0.7.7"
version = "0.7.8"

[deps]
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
Expand Down
2 changes: 2 additions & 0 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ function write(fn::AbstractString, ga::GeoArray; nodata::Union{Nothing,Real}=not
data[m] .= nodata
data = Array{dtype}(data)
use_nodata = true
elseif !isnothing(nodata)
use_nodata = true
end

try
Expand Down
9 changes: 8 additions & 1 deletion test/test_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,17 @@ end
GeoArrays.read(fn)
fn = GeoArrays.write!(joinpath(tempdir(), "test_nodata.img"), ga, 1)
GeoArrays.read(fn)
ga = GeoArray(fill(0, (100, 200, 3)))
fn = GeoArrays.write(joinpath(tempdir(), "test_nodata_hardcoded.tiff"), ga; nodata=0)
ga = GeoArrays.read(fn)
@test all(ismissing.(ga))
end
@testset "COG" begin
ga = GeoArray(Array{Union{Missing,Int32}}(rand(1:10, 2048, 2048, 3)))
fn = GeoArrays.write(joinpath(tempdir(), "test_cog.tif"), ga, 1, "COG")
fn = GeoArrays.write(joinpath(testdatadir, "test_cog.tif"), ga; nodata=-1, shortname="COG", options=Dict("COMPRESSION" => "ZSTD"))
GeoArrays.read(fn)
ga = GeoArray(Array{Union{Missing,Float32}}(rand(1:10, 2048, 2048, 3)))
fn = GeoArrays.write(joinpath(testdatadir, "test_cogf.tif"), ga; nodata=Inf, shortname="COG", options=Dict("COMPRESSION" => "ZSTD"))
GeoArrays.read(fn)
end
@testset "Kwargs" begin
Expand Down

2 comments on commit 1bd263a

@evetion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/62697

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.8 -m "<description of version>" 1bd263aaea404266736ab0d73de8495fc1f13437
git push origin v0.7.8

Please sign in to comment.