Open smalers opened 3 years ago
Because the raster may have 1 or more bands, displaying a table of properties may not work well. Instead, formatting fixed-font output with information like QGIS layer properties may be needed. I wrote Python code to output raster metadata, as shown in the following log output example. The information shown can be updated over time based on what we need to see.
INFO:geoprocessor.util.qgis_util:Raster layer metadata after reading from file:
INFO:geoprocessor.util.qgis_util:Raster size = 1545 columns x 2964 rows, 7 bands
INFO:geoprocessor.util.qgis_util:Raster units per pixel x = 134.0946 y = 134.09460000000004
INFO:geoprocessor.util.qgis_util:Raster type = 2 (MultiBand)
INFO:geoprocessor.util.qgis_util:Band: Band 1
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 10.0
INFO:geoprocessor.util.qgis_util: Maximum = 197.0
INFO:geoprocessor.util.qgis_util: Mean = 74.03837159763313
INFO:geoprocessor.util.qgis_util: Range = 187.0
INFO:geoprocessor.util.qgis_util: StdDev = 52.826449068178825
INFO:geoprocessor.util.qgis_util:Band: Band 2
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 0.0
INFO:geoprocessor.util.qgis_util: Maximum = 10461.0126953125
INFO:geoprocessor.util.qgis_util: Mean = 683.9520307479949
INFO:geoprocessor.util.qgis_util: Range = 10461.0126953125
INFO:geoprocessor.util.qgis_util: StdDev = 1557.8057888084463
INFO:geoprocessor.util.qgis_util:Band: Band 3
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 0.0
INFO:geoprocessor.util.qgis_util: Maximum = 1.0
INFO:geoprocessor.util.qgis_util: Mean = 0.12570414201183433
INFO:geoprocessor.util.qgis_util: Range = 1.0
INFO:geoprocessor.util.qgis_util: StdDev = 0.3315164112746311
INFO:geoprocessor.util.qgis_util:Band: Band 4
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 1.0
INFO:geoprocessor.util.qgis_util: Maximum = 2.0
INFO:geoprocessor.util.qgis_util: Mean = 1.0655387717811682
INFO:geoprocessor.util.qgis_util: Range = 1.0
INFO:geoprocessor.util.qgis_util: StdDev = 0.24747470797458565
INFO:geoprocessor.util.qgis_util:Band: Band 5
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 0.0
INFO:geoprocessor.util.qgis_util: Maximum = 1.0
INFO:geoprocessor.util.qgis_util: Mean = 0.7695289940828403
INFO:geoprocessor.util.qgis_util: Range = 1.0
INFO:geoprocessor.util.qgis_util: StdDev = 0.4211353237366852
INFO:geoprocessor.util.qgis_util:Band: Band 6
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 3.0
INFO:geoprocessor.util.qgis_util: Maximum = 20.0
INFO:geoprocessor.util.qgis_util: Mean = 12.176085207100591
INFO:geoprocessor.util.qgis_util: Range = 17.0
INFO:geoprocessor.util.qgis_util: StdDev = 5.664749955305544
INFO:geoprocessor.util.qgis_util:Band: Band 7
INFO:geoprocessor.util.qgis_util: Data type = 6 Float32
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source data type = 6 Float32
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = -3.3999999521443642e+38
INFO:geoprocessor.util.qgis_util: Minimum = 2018.0
INFO:geoprocessor.util.qgis_util: Maximum = 2050.0
INFO:geoprocessor.util.qgis_util: Mean = 2020.2559952662723
INFO:geoprocessor.util.qgis_util: Range = 32.0
INFO:geoprocessor.util.qgis_util: StdDev = 6.112378126243373
INFO:geoprocessor.util.qgis_util:Data provider:
INFO:geoprocessor.util.qgis_util: Extent: <QgsRectangle: 472373.09999999997671694 4145741.6055999998934567, 679549.25699999998323619 4543198>
INFO:geoprocessor.util.qgis_util: DPI: -1
INFO:geoprocessor.util.qgis_util: Has pyramids: False
See also the Python code to print raster metadata: log_raster_metadata
I also found the following:
I updated the GeoProcessor logging to be formatted as follows. Not all of this may be available or useful for InfoMapper raster layer properties output, but I recommend including what is available in the Leaflet raster API to help people like me understand the data to help with troubleshooting. I need to improve formatting of the floating point numbers.
INFO:geoprocessor.util.qgis_util:Raster properties:
INFO:geoprocessor.util.qgis_util: CRS = EPSG:4326
INFO:geoprocessor.util.qgis_util: Raster size = 1753 columns x 2749 rows, 1 bands
INFO:geoprocessor.util.qgis_util: Raster units per pixel x = 0.0012846020640274272 y = 0.0012846020640274267
INFO:geoprocessor.util.qgis_util: Raster type = 0 (Gray or undefined)
INFO:geoprocessor.util.qgis_util: Data provider:
INFO:geoprocessor.util.qgis_util: Raster provider type = gdal
INFO:geoprocessor.util.qgis_util: Extent: <QgsRectangle: -105.30753755881124789 37.47488840567542212, -103.05563014057116789 41.00625947968681828>
INFO:geoprocessor.util.qgis_util: DPI: -1
INFO:geoprocessor.util.qgis_util: Has pyramids: False
INFO:geoprocessor.util.qgis_util: Is editable: False
INFO:geoprocessor.util.qgis_util: Last error: Not implemented
INFO:geoprocessor.util.qgis_util: Last error format: text/plain
INFO:geoprocessor.util.qgis_util: Last error caption: Not implemented
INFO:geoprocessor.util.qgis_util: Band: Band 1
INFO:geoprocessor.util.qgis_util: Data type = 1 Byte
INFO:geoprocessor.util.qgis_util: Source data type = 1 Byte
INFO:geoprocessor.util.qgis_util: Band offset = 0.0
INFO:geoprocessor.util.qgis_util: Band scale = 1.0
INFO:geoprocessor.util.qgis_util: No data:
INFO:geoprocessor.util.qgis_util: User nodata values = []
INFO:geoprocessor.util.qgis_util: Source has nodata value = True
INFO:geoprocessor.util.qgis_util: Source nodata value = 127.0
INFO:geoprocessor.util.qgis_util: Statistics:
INFO:geoprocessor.util.qgis_util: Minimum = 1.0
INFO:geoprocessor.util.qgis_util: Maximum = 122.0
INFO:geoprocessor.util.qgis_util: Mean = 8.680541727971177
INFO:geoprocessor.util.qgis_util: Range = 121.0
INFO:geoprocessor.util.qgis_util: StdDev = 24.35763054013518
The new changes have been pushed. It will show the properties for the raster and each band in the raster. I'll wait to close until some feedback has been given.
Here are my comments:
Bands
to Number of Bands
.Has Missing Value
to Has No Data Value
and Missing Value
to No Data Value
. This terminology is documented in GDAL and seems common for rasters. # Data types from: https://docs.qgis.org/latest/en/docs/user_manual/processing_algs/gdal/rasterprojections.html
# #warp-reproject
data_types = {
0: "Unknown",
1: "Byte",
2: "Int16",
3: "UInt16",
4: "UInt32",
5: "Int32",
6: "Float32",
7: "Float64",
8: "CInt16",
9: "CInt32",
10: "CFloat32",
11: "CFloat64"
}
Also, change the top of the output to the following, shown as literal Markdown so you can copy and paste. Clean up if necessary.
# Layer Properties
Raster layers have the following properties:
1. Raster layers contain equal-sized grid cells with dimensional units that match the coordinate reference system. Raster layers contain one or more bands, each of which have a data type and contain values for the raster cells. Mouse over a cell or click on a cell to see the cell's data value. Cell values can can also have no data value.
2. Layer metadata, which is information about the layer (see the ***Layer Metadata*** and ***Layer Configuration Properties*** sections below).
Everything has been taken care of except for 4 and 6.
instanceof
, as I'm getting compiling errors if I try to compare a cell value with Byte
or Int16
. Also, typeof
returns 1 of a few different broad types such as string, object, number, etc. Maybe I just need to do more TypeScript type research?Be careful with data type. The raster data type is that used by the raster library, not simply the data type from "type". If only a language data type is used, that might need to be specifically noted. I'm more interested in the type that is available from raster API because that can be used to compare when moving rasters between technologies to see if things are consistent.
The Properties kebab men needs to be enabled for raster layers. It would be good to list the number of bands, width, height, etc., If nothing else than for troubleshooting.