diff --git a/Project.toml b/Project.toml index 15b84c6..7e029da 100644 --- a/Project.toml +++ b/Project.toml @@ -10,8 +10,6 @@ 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" @@ -19,6 +17,7 @@ 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] diff --git a/src/GDAL/GDAL.jl b/src/GDAL/GDAL.jl index 8f930a3..6fc67aa 100644 --- a/src/GDAL/GDAL.jl +++ b/src/GDAL/GDAL.jl @@ -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") diff --git a/src/MFDataset/main_MFDataset.Jl b/src/MFDataset/main_MFDataset.Jl index 57e9b83..d3977d7 100644 --- a/src/MFDataset/main_MFDataset.Jl +++ b/src/MFDataset/main_MFDataset.Jl @@ -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)) @@ -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) @@ -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)