Skip to content

Commit

Permalink
rm GDAL.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Jan 21, 2024
1 parent 06c1a95 commit 64ab651
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0"
DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Extents = "411431e0-e8b7-467b-b5e0-f676ba4f2910"
GDAL = "add2ef01-049f-52c4-9ee2-e494f65e021a"
GDAL_jll = "a7073274-a066-55f0-b90d-d619367d196c"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Rasters = "a3a2b9e3-a471-40c9-b274-f788e487c689"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99"

[weakdeps]
Expand Down
4 changes: 2 additions & 2 deletions src/GDAL/GDAL.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using GDAL
using GDAL_jll: gdalinfo_path, ogrinfo_path
using ArchGDAL.GDAL
using ArchGDAL.GDAL.GDAL_jll: gdalinfo_path, ogrinfo_path

include("gdal_basic.jl")
include("gdal_polygonize.jl")
Expand Down
22 changes: 20 additions & 2 deletions src/MFDataset/main_MFDataset.Jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ end
Base.getindex(v::MFVariable, i) = v.vars[i]


function Base.getindex(v::MFVariable{T,3}, i, j; dims=3) where {T}
# dims = 3
function Base.getindex(v::MFVariable{T,3}, i, j; ) where {T}
ntime = map(x -> size(x, 3), v.vars) |> sum
nlon, nlat = size(v.vars[1])[1:2]
i != Colon() && (nlon = length(i))
Expand All @@ -58,7 +59,6 @@ function Base.getindex(v::MFVariable{T,3}, i, j; dims=3) where {T}
nlat == 1 && (j = [j])

res = zeros(T, nlon, nlat, ntime)
# obj_size(res)
i_beg = 0
@inbounds for var in v.vars
_ntime = size(var, 3)
Expand All @@ -71,6 +71,24 @@ function Base.getindex(v::MFVariable{T,3}, i, j; dims=3) where {T}
# cat(res...; dims)
end


function Base.getindex(v::MFVariable{T,2}, i, j) where {T}
ntime = length(v.vars)
nlon, nlat = size(v.vars[1])[1:2]
i != Colon() && (nlon = length(i))
j != Colon() && (nlat = length(j))
nlon == 1 && (i = [i])
nlat == 1 && (j = [j])

res = zeros(T, nlon, nlat, ntime)
k = 0
@inbounds for var in v.vars
k += 1
res[:, :, k] .= var[i, j]
end
res
end

function get_chunk(m::MFDataset, k; InVars=m.bands)
ii, jj, _ = m.chunks[k]
map(band -> m[band][ii, jj], InVars)
Expand Down

0 comments on commit 64ab651

Please sign in to comment.