rgisr-rastergeotiff

The GeoTIFF file appears to have missing values, but they are visible in a plot


With the following code, I am downloading the current GeoTIFF from Dipartimento Protezione Civile in Italy, which is a radar composite.

When I display the data with a plot, I can see some values.

However, the summary of the file does not show any values present (min and max).

What could I be missing (besides the min and max values ;))?

Thank you.

library(terra)
library(httr)

get_time_url_link<-"https://radar-api.protezionecivile.it/wide/product/findLastProductByType?type=VMI"
  res <- httr::GET(url = paste0(get_time_url_link))
  cont<-content(res)
  
  get_tiff_url_link<-"https://radar-api.protezionecivile.it/wide/product/downloadProduct"
  
  
  headers = c(
    `Content-Type` = 'application/json'
  )
  
  #data = '{"productType":"VMI","productDate":"1681284300000"}'
  data = paste0("{\"productType\":\"VMI\",\"productDate\":\"",cont$lastProducts[[1]]$time,"\"}")
  res <- httr::POST(url = paste0(get_tiff_url_link), httr::add_headers(.headers=headers), body = data)
  cont<-content(res,"raw")
 
  bin <- content(res, "raw")
  writeBin(bin, "italy.tiff")
  italy_raster <- rast("italy.tiff")
  plot(italy_raster)

Here you can see the print out:

class       : SpatRaster 
dimensions  : 1400, 1200, 1  (nrow, ncol, nlyr)
resolution  : 0.01329435, 0.00913136  (x, y)
extent      : 4.523392, 20.47661, 35.06509, 47.84899  (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 (EPSG:4326) 
source      : italy.tiff 
name        : italy 

Here is the plot:

enter image description here


Solution

  • The min and max values are not shown because the file does not report them. You could compute them with

    setMinMax(italy_raster)
    

    And now we see

    italy_raster
    #class       : SpatRaster 
    #dimensions  : 1400, 1200, 1  (nrow, ncol, nlyr)
    #resolution  : 0.01329435, 0.00913136  (x, y)
    #extent      : 4.523392, 20.47661, 35.06509, 47.84899  (xmin, xmax, ymin, ymax)
    #coord. ref. : lon/lat WGS 84 (EPSG:4326) 
    #source      : italy.tiff 
    #name        : italy 
    #min value   : -9999 
    #max value   :    37