463 | | === My Analysis Reports === |
464 | | * [https://docs.google.com/document/d/15eL7Dvgf_dpS8fUHTdQKfj_6Xz9SuqMjpiY_9QqUTho/edit Revised Proposal of Creating Distance Surface in PostGIS Raster] |
| 463 | === Analysis Report === |
| 464 | '''Revised Proposal of Creating Distance Surface in PostGIS Raster''' |
| 465 | |
| 466 | * '''Case 1 - One-Point Source'''[[BR]] |
| 467 | To create distance surface from source data containing only one point geometry as the source point. |
| 468 | * Inputs: |
| 469 | * geometry - One single PostGIS geometry to create distance surface from |
| 470 | * geographic extent - Dimension of the output raster |
| 471 | * georeferencing - Information of how the raster is georeferenced |
| 472 | * maximum distance - The threshold that the accumulative distance values cannot exceed. When exceeding this value, NoData will be assigned for the output pixel value. The default threshold is to the edge of the output raster extent. |
| 473 | * Output:[[BR]] |
| 474 | Generate one single raster (rectan) in which pixel values represent the Euclidean distance from the center of the pixels to the center of the source point. |
| 475 | * Proposed Algorithm: |
| 476 | * Calculate Euclidean distance using the coordinates of the center of pixel and the center of the source point (d(dx,dy) = sqrt(dx^2 + dy^2)). If distance exceed max_distance specified, NoData value is used instead. |
| 477 | * Create a single raster with distance as pixel value (ST_RasterFromText()?) using dimensions and georeferencing information specified |
| 478 | |
| 479 | * '''Case 2 - Multi-point Source'''[[BR]] |
| 480 | To create distance surface from source data containing multiple point geometries as the source points. |
| 481 | * Inputs: |
| 482 | * geometry - Multiple PostGIS geometries to create distance surface from |
| 483 | * geographic extent - Dimension of the output raster |
| 484 | * georeferencing - Information of how the raster is georeferenced |
| 485 | * maximum distance - The threshold that the accumulative distance values cannot exceed. When exceeding this value, NoData will be assigned for the output pixel value. The default threshold is to the edge of the output raster extent. |
| 486 | * Output:[[BR]] |
| 487 | Generate one single raster (rectan) in which pixel values represent the Euclidean distance from the center of the pixels to the center of its nearest source point. |
| 488 | * Proposed Algorithm: |
| 489 | * Scan through pixels, compute the KNN index for each pixel to its nearest source point, assign Euclidean distance using the coordinates of the center of the pixel and the center of its nearest source point (d(dx,dy) = sqrt(dx^2 + dy^2)). If distance exceed max_distance specified, NoData value is used instead. |
| 490 | * Create a single raster with distance as pixel value (ST_RasterFromText()?) using dimensions and georeferencing information specified |
| 491 | * Scalability: |
| 492 | * In case of source data being large size dataset (e.g. containing billions of points), the KNN indexing approach should be able to help us in quickly identifying the nearest point to the pixel without rescanning all the points for every pixel. |
| 493 | * Possibility: |
| 494 | * It is possible to work with line geometries and polygon geometries utilizing the algorithms for the multi-point solution |
| 495 | * distance will be computed from the center of each pixel to the center of its nearest pixel on the line or polygon |
| 496 | * In case of single line or polygon geometry, the default output raster extent will be the same as the source line or polygon. |
| 497 | * Note that pixels within the polygon will be assigned “0” distance or NoData value |
| 498 | * Performance: |
| 499 | * The speed depends on the number of source points, as well as the size of the produced raster. |
| 500 | * By utilizing KNN indexing, we expect the speed to be independent from the number of the source points. |
| 501 | * There are limits of the data structure imposed by the database needed to be considered like the fact that all the geometries are stored in different rows. |
| 502 | * Flexibility: |
| 503 | * The solution for calculating Euclidean distance can be implemented for other kinds of distances (e.g. cost-weighted distance). Euclidean distance will be used as the base layer. The cost-weighted distance could be calculated from the Euclidean distance surface with the cost surface. ST_MapAlgebraExpr two raster bands version could be utilized for computing. |