|
3 | 3 | Pkg.add("TIFFDatasets")</code></pre><p>Or by typing <code>]add TIFFDatasets</code> using the package manager REPL-mode.</p><h2 id="API-reference"><a class="docs-heading-anchor" href="#API-reference">API reference</a><a id="API-reference-1"></a><a class="docs-heading-anchor-permalink" href="#API-reference" title="Permalink"></a></h2><article><details class="docstring" open="true"><summary id="TIFFDatasets.TIFFDataset"><a class="docstring-binding" href="#TIFFDatasets.TIFFDataset"><code>TIFFDatasets.TIFFDataset</code></a> — <span class="docstring-category">Type</span></summary><section><div><pre><code class="language-julia hljs">ds = TIFFDataset(fname::AbstractString,mode = "r"; varname = "band", |
4 | 4 | projection = "EPSG:4326", |
5 | 5 | catbands = false, |
6 | | - dimnames = ("cols","rows","bands"))</code></pre><p>Create a data set structure from the GeoTIFF file name <code>fname</code> using <a href="https://github.com/yeesian/ArchGDAL.jl">ArchGDAL</a>. The data variable will be called <code>varname</code> (followed by the band number). The dataset <code>ds</code> will also have the virtual variables <code>x</code>, <code>y</code> and <code>lon</code>, <code>lat</code> representing the projected coordinates (as defined in the GeoTIFF file) and the corresponding longitude/latitude (using the projection as defined by the <code>projection</code> parameter). The names of the dimensions can be adapted using the parameter <code>dimnames</code>. The type of projection can be checked with the attributes (<code>grid_mapping_name</code>, <code>longitude_of_central_meridian</code>, <code>false_easting</code>, <code>false_northing</code>, <code>latitude_of_projection_origin</code>, <code>scale_factor_at_central_meridian, longitude_of_prime_meridian</code>, <code>semi_major_axis</code>, <code>inverse_flattening</code>, ... depending on the projection used) of the virtual variable <code>crs</code>. The attribute <code>crs_wkt</code> describes the coordinate reference system as so-called <a href="https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems">"Well-Known Text"</a></p><p>In addition to the CF conventions, there is also the attribute <code>GeoTransform</code> [1] with six numbers describing a linear mapping between indices and the projected coordinates. For the point <code>(i,j)</code> the projected coordinates are computed as:</p><pre><code class="language-julia hljs">shift = 0.5 # center |
| 6 | + dimnames = ("cols","rows","bands"))</code></pre><p>Create a data set structure from the file name <code>fname</code> using <a href="https://github.com/yeesian/ArchGDAL.jl">ArchGDAL</a>. The file format must be suppored GDAL for example GeoTIFF or georeferenced JPEG 2000 files. The data variable will be called <code>varname</code> (followed by the band number). The dataset <code>ds</code> will also have the virtual variables <code>x</code>, <code>y</code> and <code>lon</code>, <code>lat</code> representing the projected coordinates (as defined in the GeoTIFF file) and the corresponding longitude/latitude (using the projection as defined by the <code>projection</code> parameter). The names of the dimensions can be adapted using the parameter <code>dimnames</code>. The type of projection can be checked with the attributes (<code>grid_mapping_name</code>, <code>longitude_of_central_meridian</code>, <code>false_easting</code>, <code>false_northing</code>, <code>latitude_of_projection_origin</code>, <code>scale_factor_at_central_meridian, longitude_of_prime_meridian</code>, <code>semi_major_axis</code>, <code>inverse_flattening</code>, ... depending on the projection used) of the virtual variable <code>crs</code>. The attribute <code>crs_wkt</code> describes the coordinate reference system as so-called <a href="https://en.wikipedia.org/wiki/Well-known_text_representation_of_coordinate_reference_systems">"Well-Known Text"</a></p><p>In addition to the CF conventions, there is also the attribute <code>GeoTransform</code> [1] with six numbers describing a linear mapping between indices and the projected coordinates. For the point <code>(i,j)</code> the projected coordinates are computed as:</p><pre><code class="language-julia hljs">shift = 0.5 # center |
7 | 7 | x_geo = GeoTransform[1] + (i-shift) * GeoTransform[2] + (j-shift) * GeoTransform[3] |
8 | 8 | y_geo = GeoTransform[4] + (i-shift) * GeoTransform[5] + (j-shift) * GeoTransform[6]</code></pre><p>Setting <code>catbands</code> to true, will concatenate all bands into a single variable called <code>varname</code>. If <code>catbands</code> is true, it is the user's responsibility to check that all bands have the same no-data value, offset and scale factor. Check with the command line tool <code>gdalinfo filename</code> or use ArchGDAL to inspect the file. If this is not the case, <code>catbands = true</code> should not be used.</p><p>Example:</p><pre><code class="language-julia hljs">using TIFFDatasets |
9 | 9 | fname = download("https://data-assimilation.net/upload/Alex/TIFF/S2_1-12-19_48MYU_0.tif") |
|
21 | 21 |
|
22 | 22 | julia> @time sum(ds["band1"][:,:]) # much faster |
23 | 23 | 0.000381 seconds (765 allocations: 302.781 KiB) |
24 | | -6403.5527f0</code></pre><p>The dataset can be manipulated using the functions from <a href="https://github.com/JuliaGeo/CommonDataModel.jl">CommonDataModel.jl</a>. Writing to a file is currently not supported (pull-requests are welcome!).</p><p>Reference:</p><ul><li>[1] <a href="https://gdal.org/tutorials/geotransforms_tut.html#transformation-from-image-coordinate-space-to-georeferenced-coordinate-space">GDAL GeoTransform</a></li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/Alexander-Barth/TIFFDatasets.jl/blob/69d8a7c725d751f828d7bd09c018ab4915f2e013/src/TIFFDatasets.jl#L141-L219">source</a></section></details></article><article><details class="docstring" open="true"><summary id="TIFFDatasets.TIFFDataset-Tuple{AbstractVector{<:AbstractString}, Vararg{Any}}"><a class="docstring-binding" href="#TIFFDatasets.TIFFDataset-Tuple{AbstractVector{<:AbstractString}, Vararg{Any}}"><code>TIFFDatasets.TIFFDataset</code></a> — <span class="docstring-category">Method</span></summary><section><div><pre><code class="language-julia hljs">TIFFDataset(fnames::AbstractVector{<:AbstractString}; |
25 | | - aggdim=name, isnewdim=false)</code></pre><p>Concatenate TIFF files <code>fnames</code> along the dimension specified with <code>aggdim</code>. The parameter <code>isnewdim</code> must be true for new dimensions not initially present in the file. See CommonDataModel.MFDataset for more information of the arguments.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/Alexander-Barth/TIFFDatasets.jl/blob/69d8a7c725d751f828d7bd09c018ab4915f2e013/src/TIFFDatasets.jl#L516-L525">source</a></section></details></article></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="examples/flood_example/">MODIS/Aqua+Terra Global Flood Product »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a>, <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a></p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <span class="colophon-date" title="Tuesday 17 February 2026 11:29">Tuesday 17 February 2026</span>. Using Julia version 1.12.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
| 24 | +6403.5527f0</code></pre><p>The dataset can be manipulated using the functions from <a href="https://github.com/JuliaGeo/CommonDataModel.jl">CommonDataModel.jl</a>. Writing to a file is currently not supported (pull-requests are welcome!).</p><p>Reference:</p><ul><li>[1] <a href="https://gdal.org/tutorials/geotransforms_tut.html#transformation-from-image-coordinate-space-to-georeferenced-coordinate-space">GDAL GeoTransform</a></li></ul></div><a class="docs-sourcelink" target="_blank" href="https://github.com/Alexander-Barth/TIFFDatasets.jl/blob/1a524f148203453c094895908099d76c503e9f0a/src/TIFFDatasets.jl#L141-L221">source</a></section></details></article><article><details class="docstring" open="true"><summary id="TIFFDatasets.TIFFDataset-Tuple{AbstractVector{<:AbstractString}, Vararg{Any}}"><a class="docstring-binding" href="#TIFFDatasets.TIFFDataset-Tuple{AbstractVector{<:AbstractString}, Vararg{Any}}"><code>TIFFDatasets.TIFFDataset</code></a> — <span class="docstring-category">Method</span></summary><section><div><pre><code class="language-julia hljs">TIFFDataset(fnames::AbstractVector{<:AbstractString}; |
| 25 | + aggdim=name, isnewdim=false)</code></pre><p>Concatenate TIFF files <code>fnames</code> along the dimension specified with <code>aggdim</code>. The parameter <code>isnewdim</code> must be true for new dimensions not initially present in the file. See CommonDataModel.MFDataset for more information of the arguments.</p></div><a class="docs-sourcelink" target="_blank" href="https://github.com/Alexander-Barth/TIFFDatasets.jl/blob/1a524f148203453c094895908099d76c503e9f0a/src/TIFFDatasets.jl#L518-L527">source</a></section></details></article></article><nav class="docs-footer"><a class="docs-footer-nextpage" href="examples/flood_example/">MODIS/Aqua+Terra Global Flood Product »</a><div class="flexbox-break"></div><p class="footer-message">Powered by <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a>, <a href="https://github.com/fredrikekre/Literate.jl">Literate.jl</a> and the <a href="https://julialang.org/">Julia Programming Language</a></p></nav></div><div class="modal" id="documenter-settings"><div class="modal-background"></div><div class="modal-card"><header class="modal-card-head"><p class="modal-card-title">Settings</p><button class="delete"></button></header><section class="modal-card-body"><p><label class="label">Theme</label><div class="select"><select id="documenter-themepicker"><option value="auto">Automatic (OS)</option><option value="documenter-light">documenter-light</option><option value="documenter-dark">documenter-dark</option><option value="catppuccin-latte">catppuccin-latte</option><option value="catppuccin-frappe">catppuccin-frappe</option><option value="catppuccin-macchiato">catppuccin-macchiato</option><option value="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <a href="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <span class="colophon-date" title="Tuesday 17 February 2026 11:32">Tuesday 17 February 2026</span>. Using Julia version 1.12.5.</p></section><footer class="modal-card-foot"></footer></div></div></div></body></html> |
0 commit comments