# Display ArchGDAL geotiff raster wants unsigned type?

**URL:** https://discourse.julialang.org/t/display-archgdal-geotiff-raster-wants-unsigned-type/82813
**Category:** Geo
**Created:** [June 15, 2022, 1:54pm UTC](https://discourse.julialang.org/t/display-archgdal-geotiff-raster-wants-unsigned-type/82813 "2022-06-15T13:54:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![floswald](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/floswald/32/195_2.png) [@floswald](https://discourse.julialang.org/u/floswald)
#### Post date: [June 15, 2022, 1:54pm UTC](https://discourse.julialang.org/t/display-archgdal-geotiff-raster-wants-unsigned-type/82813/1 "2022-06-15T13:54:16Z")

</div>

I wanted to look at [this raster](https://data.humdata.org/dataset/france-high-resolution-population-density-maps-demographic-estimates) with ArchGDAL:

```julia
using ArchGDAL
(loaded raster from disk)

julia> e
GDAL Dataset (Driver: GTiff/GeoTIFF)
File(s): 
  /Users/florian.oswald/Downloads/population_fra_2019-07-01_geotiff/population_fra_2019-07-01.tif
  /Users/florian.oswald/Downloads/population_fra_2019-07-01_geotiff/population_fra_2019-07-01.tif.aux.xml

Dataset (width x height): 52928 x 35136 (pixels)
Number of raster bands: 1
  [GA_ReadOnly] Band 1 (Gray): 52928 x 35136 (Float64)

julia> ArchGDAL.imread(e)
ERROR: TypeError: in Normed, in T, expected T<:Unsigned, got Type{Float64}
Stacktrace:
  [1] (::ArchGDAL.var"#112#113")(img::Matrix{Float64})
```

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [June 15, 2022, 2:50pm UTC](https://discourse.julialang.org/t/display-archgdal-geotiff-raster-wants-unsigned-type/82813/2 "2022-06-15T14:50:05Z")

</div>

Geotiff float32 and unsigned are two very different beasts. `float32` are grids whilst 1 byte are images. 2 bytes are fuzzy but according to _my_ definition they are grids as well.  
Your guy is pretty big, doesn’t look so from size because the file is highly compressed. Don’t know how to deal with it in ArchGDAL but in GMT

```julia
using GMT
G = gmtread("population_fra_2019-07-01.tif");

typeof(G)
GMTgrid{Float32, 2}

size(G)
(35136, 52928)

imshow(G)

```

 ![GMTjl_tmp](https://global.discourse-cdn.com/julialang/original/3X/1/2/123527a22c02c70e9306ca173076722e10b1d8af.png)

---

<div class="post-metadata">

### Author: ![visr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/visr/32/17204_2.png) [@visr](https://discourse.julialang.org/u/visr)
#### Post date: [June 15, 2022, 8:02pm UTC](https://discourse.julialang.org/t/display-archgdal-geotiff-raster-wants-unsigned-type/82813/3 "2022-06-15T20:02:06Z")

</div>

`ArchGDAL.imread` is meant to read raster images to Julia images (matrix of colors). This raster is not an image but Float64 data in the range 0 to 367.

It is probably better to read the data using `ArchGDAL.readraster` or `ArchGDAL.read`, as Float64 data. If you want to plot that data as an image, you can make use of the tools of Images.jl, for instance:

```julia
using ImageCore

data = rand(3, 4) .* 367
scaled_data = data ./ 367
Gray.(scaled_data)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/0/3/033a063463d016bbaf46eeb4f8e16bddd802d115.png)

The error is not great however. It would be appreciated if you could file an issue, referencing this thread, probably we can make it better.
