Reading Satellite Data


#1

Anybody please tell me how to read Geotiff format files?
These are satellite data.
I bet there is already a Julia package for this!


#2

ArchGDAL should do what you want:
http://yeesian.com/ArchGDAL.jl/latest/rasters.html


#3

Using this PR might make it easier: https://github.com/yeesian/ArchGDAL.jl/pull/76


#4

Also, it takes a bit of time to put it all together (which I think above PR resolves). Something like this should work:

    AG = ArchGDAL
    out = AG.registerdrivers() do
        AG.read(filepath) do dataset
            band = AG.getband(dataset, bandnr)
            w, h = AG.width(band), AG.height(band)
            # scale, off = AG.getscale(band), AG.getoffset(band)
            na = AG.getnodatavalue(band)
            mat = convert(Matrix{T}, AG.read(band))
            gt = AG.getgeotransform(dataset)
            dx, dy = gt[2], -gt[end]
            x0 = gt[1] + dx/2
            x1 = x0 + (w-1) * dx
            y1 = gt[4] - dy/2
            y0 = y1 - (h-1)*dy

            proj4 = strip(AG.toPROJ4(AG.importWKT(AG.getproj(dataset))))
            (x0:dx:x1, y0:dy:y1, mat, proj4) # x-range, y-range, values, projection
        end
    end

see https://github.com/yeesian/ArchGDAL.jl/issues/68


#5

Note that geotiff files can hold both images (multi-band images) or grids. In the second case each node stores a 4 bytes float, which is often used to store DEM (Digital Elevation Model) values.

GMT.jl reads geotiff files nativelly (well, actually via GDAL too). If your case is a simple RGB image, something like this will get you the data (and metadata) in Julia

I = gmtread("the_file_name.tif", img=true);

#6

I am afraid that the gmtread fails quite spectacularly. Julia version 1.1.0 running on Windows 64
Can someone advise where I should file a bug?

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.

Blockquote
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.

Exception: EXCEPTION_ACCESS_VIOLATION at 0xb36e4c0 – getindex at .\array.jl:730 [inlined] macro expansion at .\multidimensional.jl:671 [inlined] macro expansion at .\cartesian.jl:64 [inlined] macro expansion at .\multidimensional.jl:666 [inlined] _unsafe_getindex! at .\multidimensional.jl:662 [inlined] _unsafe_getindex at .\multidimensional.jl:656 in expression starting at C:\Users\hearn\Documents\Satellite\Crawley\gmtread.jl:3 macro expansion at .\multidimensional.jl:669 [inlined] macro expansion at .\cartesian.jl:64 [inlined] macro expansion at .\multidimensional.jl:666 [inlined] _unsafe_getindex! at .\multidimensional.jl:662 [inlined] _unsafe_getindex at .\multidimensional.jl:656 _getindex at .\multidimensional.jl:642 [inlined] getindex at .\abstractarray.jl:927 unknown function (ip: 000000000B36E1CA) jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864 jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219 get_image at C:\Users\hearn.julia\packages\GMT\v32Hn\src\gmt_main.jl:519 GMTJL_Get_Object at C:\Users\hearn.julia\packages\GMT\v32Hn\src\gmt_main.jl:850 gmt at C:\Users\hearn.julia\packages\GMT\v32Hn\src\gmt_main.jl:264

Blockquote


#7

Reading data with GMT.jl is now working!!
Note- you must install Ghostscript https://www.ghostscript.com/download/gsdnld.html
and the GMT software http://w3.ualg.pt/~jluis/mirone/downloads/gmt.html
before adding the GMT package.
In the GMT installer at the Choose Components stage check the DCW component also.

Huge thanks to @joa-quim for all the help.