53 | | * It would be interesting to have an option to create a second band with the length of the line or the area of polygon intersecting each pixel. This band could then be used in a subsequent ST_Union() to decide which pixel value to burn (the one with the longest length of the biggest area). For this to be useful ST_Union should work with a ST_MapAlgebra(rast1, rast2) able to refer to pixel value in any band. e.g. rast1.2 referring to the pixel value in the second band. The ST_Union(rast, 'MAX_LENGTH') aggregate could then be implemented with the following state expression: 'CASE WHEN rast1.2 > rast2.2 THEN rast1.1 ELSE rast2.1 ENDIF'. ST_Union(rast, 'MAX_COMBINED_LENGTH') could also use a ST_MapAlgebra(rast1, rast2) able to take a custom user function. The state function that would accumulate, in a temporary table, the total length for a same value over every overlapping pixels and the final function would determine which of the values from the table is the right one to burn in the final raster pixel. |
| 53 | * It would be interesting to have an option to create a second band with the length of the line or the area of polygon intersecting each pixel. This band could then be used in a ST_Union(rast, 'MAX_LENGTH') or a ST_Union(rast, 'MAX_LENGTH') function burning the value of the line having the longest intersection with the pixel or the value of the polygon having the biggest intersecting area. For this to be useful ST_Union should work with a ST_MapAlgebra(rast1, rast2) able to refer to pixel value in any band (e.g. rast1.2 referring to the pixel value in the second band). The ST_Union(rast, 'MAX_LENGTH') aggregate could then be implemented with the following state expression: 'CASE WHEN rast1.2 > rast2.2 THEN rast1.1 ELSE rast2.1 ENDIF'. Otherwise we would have to imbricate four Mapalgebra functions. ST_Union(rast, 'MAX_COMBINED_LENGTH') could use a ST_MapAlgebra(rast1, rast2) able to take a custom user function. The state function would accumulate, in a temporary table, the total intersecting length or area for a same value over every overlapping pixels and the final function would determine which of the values from the temporary table would be the right one to burn in the final raster pixel. |