Open smalers opened 3 years ago
Here are some thoughts:
Here is an idea...
For the code that handles the popup, can it retain a list/array of triggering items with the raster cell that triggered that call? Then whenever there is an event handled, the code could go through that short array/list as follows:
This simple logic would handle multiple raster events triggered for the same raster cell regardless of order. The vector output would also need to be handled as before.
I believe I was able to find a solution for this using a combination of the ideas above from Steve and some of my own. I've done all the testing I could think of on my end, but I'm not convinced it's flawless. I feel like that should be the outlook for everything however. I will wait to close until more rigorous testing has been done / more examples have been used.
This seems to be somewhat working. See the image below. I mentioned before adding the text label to the right of the raster number. That way it is easier to interpret the numbers. the label may need to be truncated so the popup does not get wide.
There does seem to be some lag where the popup does not update when the mouse is moved. I'm using the LandDevelopment.tif and Municipality.tif layers in the following repository: https://github.com/OpenWaterFoundation/owf-infomapper-coagtransfer-data-wwr/tree/main/Rasters
Now that I've been working with the graduated symbol, adding the label to the right of the value in the popup is more complicated. It makes sense to do it for categorized symbol but graduated might need more formatting. We might need to be able to handle properties in the format for the popup to look good like:
${cellValue} - year of development
This would also allow modifier to be used like ${cellValue}.format('%.4f')
if floating point and want to control the number of digits. This would need to be specified in the event configuration somehow. We can discuss.
In reviewing the legend for recent graduated classification, I am seeing the following, but only after interacting with the map for a while? The behavior should be as follows:
It is also a bug that when moving into a clear area (no color from the legend), there should probably be no data
shown in the popup but there are clearly cases where something is confused.
In either case, the popup should be driven by the number of selected (visible) raster layers. There may be a bug in the analysis for this map because the already developed cells black
should not be grown onto but different densities are showing this. So, the bug allowed me to see something unexpected.
I changed the classification file to be as follows, with Nodata
added (software should handle by ignoring case). Note also that a single raster is shown in the popup below (rather than 3 as in the previous example), so not sure what is going on. The intent is that if the raster value is "no data", it will show as totally transparent. The raster library must be doing this already by not trying to render anything in those cells but I think showing explicitly in the legend will avoid confusion. The popup does show "no data". I think we need to clarify in the documentation what the software behavior is. Does it automatically handle no data by showing transparent? If so, then allowing an item in the legend would be an optional thing and it may actually be of interest to color no data different than the default, such as solid black, especially when evaluating whether analysis logic is correct. Note that *
in the classification file means "all other data value that have not been handled by other rules and are not 'no data'".
I suspect that the Nodata
line I added is being ignored because I changed to a specific color and nothing showed. So, it would be nice if the special value Nodata
was handled and did actually render with the specified color, and by default the color would be transparent for boundary and fill. It may be a bit confusing that legend for no data is nothing, but that makes sense because if were configured with, for example, light grey for the outline then the legend would be different from the map. However, I think the user could get through this especially if it were explained with map layer documentation.
Finally, I use the term "missing data" in time series rather than "no data". This difference in language is OK. The term "no data" seems to be built into GIS and raster lingo so we should stick with that.
# Category classification table for Municipal Land Development raster.
# - the value corresponds to raster data value for year
# - set colors to indicate red for most immediate development pressure
valueMin,valueMax,color,opacity,fillColor,fillOpacity,weight,label
# 2018 Current - Black (might change to gray)
-Infinity,<=2018,#000000,1.0,#000000,0.3,2,"<= ${valueMax}"
# 2019-2020 Near-term red
>=2019,<=2020,#ff0000,1.0,#ff0000,0.3,2,"${valueMin} - ${valueMax}"
# 2021-2025 red-orange
>=2021,<=2025,#ff4500,1.0,#ff4500,0.3,2,"${valueMin} - ${valueMax}"
# 2026-2030 orange
>=2026,<=2030,#ffa500,1.0,#ffa500,0.3,2,"${valueMin} - ${valueMax}"
# 2031-2035 orange-yellow
>=2031,<=2035,#f8d568,1.0,#f8d568,0.3,2,"${valueMin} - ${valueMax}"
# 2036-2040 yellow
>=2036,<=2040,#ffff00,1.0,#ffff00,0.3,2,"${valueMin} - ${valueMax}"
# 2041-2045 yellow-green
>=2041,<=2045,#adff2f,1.0,#adff2f,0.3,2,"${valueMin} - ${valueMax}"
# 2046-2050 green
>=2046,Infinity,#00ff00,1.0,#00ff00,0.3,2,">= ${valueMin}"
# No data
Nodata,Nodata,#ffffff,1.0,#ffffff,0.0,0,"No data"
After some digging, the issue with displaying every raster layer in the popup even though selectBehavior
is set to Single was found. It was a small conditional error, and has been updated so that only the layer currently being shown on the map displays in the popup. I'm looking into the Nodata
issue next.
Merge number 2 was done, and the nodata
value for valueMin
and valueMax
is finished. Changing the colors in the classification file for nodata
will display on the map and legend. I'll keep this issue open for now in case any hidden bugs reveal themselves with testing in the coming days.
I don't think things are totally working. In the following image, if I move the mouse from right (color) to left (on gray), the popup incorrectly continues to show the color value rather than gray value. It also shows the raster values for all the layers and not just the selected/visible layer.
If I move the mouse from bottom to top into the gray area (second image below), and select the "Medium Density" raster, the popup shows no data even though it clearly is 2018.
New code has been added that takes care of the multiple issues above. Since this has given me a harder time than I initially thought, and the fact that other small bugs have popped up after previous updates, I will wait to close this until more testing has been done.
The Colorado Agricultural Water Transfer website Municipalities map has two raster layers. Is it possible to show both raster layer cell values? The popup does seem to show the correct raster cell value when moving between the cells in different raster layers.
Also, is it possible to show the lend value next to the cell value in the popup. I can shorten the legend text if necessary. Showing the text will make it easier for users to interpret the cell values.