-
Notifications
You must be signed in to change notification settings - Fork 23
Add TiledDiskArray #283
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
base: main
Are you sure you want to change the base?
Add TiledDiskArray #283
Conversation
|
Could we use this to lazily wrap a tile server? |
|
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)) |
| chunk_indices = findchunk.(chunks.chunks, I) | ||
| data_offset = OffsetArray(data, map(i -> first(i) - 1, I)...) | ||
| foreach(CartesianIndices(chunk_indices)) do ci | ||
| @show ci |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| foreach(CartesianIndices(chunk_indices)) do ci | ||
| @show ci | ||
| chunkindex = ChunkIndex(ci; offset=true) | ||
| @show chunkindex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| tilefunction | ||
| tilenum | ||
| tilesizes |
There was a problem hiding this comment.
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}
endThere was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| struct TiledDiskArray{T,N} <: AbstractChunkTiledDiskArray{T,N} | ||
| tilefunction | ||
| tilenum | ||
| tilesizes |
There was a problem hiding this comment.
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?
Add a TiledDiskArray type which handles a collection of tiles that lay in the same grid with a predictable pattern .