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

Need a way to indicate data type for GeoJSON and GeoTiff #361

Open smalers opened 3 years ago

smalers commented 3 years ago

This is a general requirement that needs to be figured out.

JSON and GeoJSON can contain integers and floating point numbers. There is no distinction between the two other than floating numbers may have a decimal point. Once read into JavaScript, all numbers are 64-bit floating point and it is not easy to determine if a number was an integer.

However, for classification and other data handling, it is helpful to know if the source data types for vector attribute table and raster bands. Because JavaScript only provides floating point numbers, additional metadata are needed.

For vector layers, it should be possible to use "foreign element" in GeoJSON to describe the metadata, but this would be a non-standard extension. Ideally it would be nice to see if anyone has done work, but if necessary we could invent something. For example, GeoProcessor could attach some data to the GeoJSON files.

For raster layers, perhaps there is some open source library code that reads the GeoTiff so that data type information can be extracted. This information is hopefully at the top of the file so that only some of the file needs to be read. Maybe the developer of the GeoTiff Leaflet code could be asked to add a way to get the original data type for each band so that we can properly handle for classification, etc. Lacking that, we could add a property on the layer to indicate the data type for each band. This is a bit tricky because it is not a single value, it is an array of types for all the bands. I found the following library. As usual, code needs to be robust. The main problem is that rereading the GeoTiff to get metadata may cause another round-trip to reload the file, deal with async issues, etc. It would be better if the package we are using provided some information.

geotiffjs

Until we get this figured out, some default behavior may not be as nice as desired or may require additional configuration because the layer properties don't provide information.

Nightsphere commented 3 years ago

I meant to leave a comment earlier saying I opened an issue to the author of the georaster-layer-for-leaflet package. He responded here.

smalers commented 3 years ago

When you get a chance you might want to explain that knowing whether it is an integer helps to format the legend, popups for data value, etc.