OpenWaterFoundation / owf-app-infomapper-ng

Open Water Foundation InfoMapper web application for menu-driven maps and visualizations, using Angular
GNU General Public License v3.0
1 stars 2 forks source link

Handle nodata value in raster popups #342

Closed smalers closed 3 years ago

smalers commented 3 years ago

The raster hover event handler is working but shows a large negative number for no data value (approximately -3.39e+38). This is probably the biggest negative 32-bit floating point number. The data type is Float32 for the raster even through integer values are stored in the cell. I need to check on how GeoProcessor/PyQGIS handles data type for each band when manipulating the raster.

The hover popup should display as Cell value: no data in this case. I recommend writing a utility function somewhere like boolean isCellValueMissing(value). The no data value is stored with the raster so need to decide how to handle that. In general, avoid many function calls to return the same value.

As for detecting the value, it may be necessary to bracket the value, which is what TSTool does, something like:

nodataValue = raster.getNoDataValue();
boolean isCellValueMissing(value) {
    // For the following need to handle case where trying to offset can't be done because value is already at end 
   // of language limit.  Not sure if trying to go outside will throw an exception or just assign to the limiting value.
    // The limiting value is OK because the check below uses >= and <=.
    nodataValueMin = noDataValue - .000001
    nodataValueMax = nodataValue + .000001
    if ( (value => nodataValueMin) && (value <= nodataValueMax) ) {
       return true;
   }
   else {
       return false;
   }
}
smalers commented 3 years ago

The Poudre Basin Information wildfire map hover popup was not initially showing the cell data value. The configuration file is below, although I think the configuration uses the classificationAttribute rather than the following. Then I realized that I had set the attribute to a string because I also had a vector layer with similar data. There needs to be a console warning in this case saying that the classificationAttribute should be a number. The number also needs to be checked to make sure it is between 1 and the number of bands in the raster.

{
  "id" : "cameron-peak-sbs-raster-event-config",
  "name": "Hover and click event handlers for cameron-peak-sbs-raster.tif",
  "description":  "Display only important user-understandable attributes.",
  "layerAttributes" : {
    "include" : [ "*" ],
    "exclude" : [],
    "formats": []
  },
  "actions": [
  ]
}

image

Nightsphere commented 3 years ago

The error handling has been updated for the classificationAttribute, and will display an appropriate warning/error message to help debug. Closing the issue.