Skip to content

Add TiledDiskArray - #283

Closed
felixcremer wants to merge 2 commits into
JuliaIO:mainfrom
felixcremer:fc/tileddiskarray
Closed

Add TiledDiskArray#283
felixcremer wants to merge 2 commits into
JuliaIO:mainfrom
felixcremer:fc/tileddiskarray

Conversation

@felixcremer

Copy link
Copy Markdown
Member

Add a TiledDiskArray type which handles a collection of tiles that lay in the same grid with a predictable pattern .

@rafaqz

rafaqz commented Oct 24, 2025

Copy link
Copy Markdown
Collaborator

Could we use this to lazily wrap a tile server?

@felixcremer

Copy link
Copy Markdown
Member Author

Main problem might be, that a Tile Server has color values and not actual array values. But this might work for wrapping a tile server and giving the RGB values from the pngs.

This would currently expect a function that would from a given tile position return a matrix of the data in this position. So we could have a function that reads the data from the tile server.

The interface we are aiming for currently is this:

using ArchGDAL

function geturl(east, north) 
    baseurl = "https://download.geoservice.dlr.de/FNF50/files"
    xsym, xval = if east < 180
        'W',180-east
    else
        'E', east-180
    end
    ysym, yval = if north < 90
        'S', 90-north
    else
        'N', north-90
    end
    xpadround = xsym * lpad(Int(round(xval, RoundDown, digits=-1)), 3, "0")
    ypadround = ysym * lpad(Int(round(yval, RoundDown, digits=-1)), 2, "0")
    xpad = xsym * lpad(xval, 3, "0")
    ypad = ysym * lpad(yval, 2,"0")
    tdm = "TDM_FNF_20_" * ypad * xpad
    join([baseurl, ypad, xpadround, tdm, tdm * "_cog.tif"], "/")
end

function gettile(east, north)
    response = HTTP.head(geturl(1,1), status_exception=false)
    if response.status == 200
        ArchGDAL.readraster("/vsicurl/"*geturl(east, north))[:,:]::Matrix{UInt8}
    else
        fill(UInt8(3), (2001,2001))
    end
end

A = DiskArrays.TiledDiskArray{UInt8,2}(gettile, (360,180), (2001,2001))

Comment thread src/chunktiledarray.jl
chunk_indices = findchunk.(chunks.chunks, I)
data_offset = OffsetArray(data, map(i -> first(i) - 1, I)...)
foreach(CartesianIndices(chunk_indices)) do ci
@show ci

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove

Comment thread src/chunktiledarray.jl
foreach(CartesianIndices(chunk_indices)) do ci
@show ci
chunkindex = ChunkIndex(ci; offset=true)
@show chunkindex

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove

Comment thread src/chunktiledarray.jl
Comment on lines +37 to +39
tilefunction
tilenum
tilesizes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you use this definition instead:

struct TiledDiskArray{T,N,F} <: AbstractChunkTiledDiskArray{T,N}
    tilefunction::F
    tilenum::NTuple{N,Int}
    tilesizes::NTuple{N,Int}
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth having the tile definition be GridChunks instead - for example the Copernicus DEM has irregular sizes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you have a link to that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread src/chunktiledarray.jl
struct TiledDiskArray{T,N} <: AbstractChunkTiledDiskArray{T,N}
tilefunction
tilenum
tilesizes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is tilesizes just tilesize? What does the pluralisation mean?

@meggart meggart mentioned this pull request Aug 6, 2026
@meggart

meggart commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Superseded by #300 sorry @felixcremer, I could not push to your branch

@meggart meggart closed this Aug 6, 2026
@felixcremer
felixcremer deleted the fc/tileddiskarray branch August 7, 2026 09:08
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

Successfully merging this pull request may close these issues.

4 participants