Changes between Version 24 and Version 25 of PostGIS_Raster_SoC_Idea_2012/Distance_Analysis_Tools/document


Ignore:
Timestamp:
Jul 12, 2012, 11:12:30 PM (12 years ago)
Author:
qliu
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • PostGIS_Raster_SoC_Idea_2012/Distance_Analysis_Tools/document

    v24 v25  
    9595
    9696'''Cons:'''
    97  * We have no idea for now about the algorithm and performance of building TIN from source geometries in PostGIS if the number of source point is very large (Constraint 7 & 8)
     97 * __We have no idea for now about the algorithm and performance of building TIN from source geometries in PostGIS if the number of source point is very large (Constraint 7 & 8)__
     98{{{
     99Comments from the Mentor:
     100Right, ST_Within(raster, geometry) does not exist. But you would work with the centroid of the pixel, which is a point and the triangle of the TIN which are polygons and there is no problem doing that with ST_Within. If you would include the pixel centroid in the TIN as stated above, you would nort even have to do that as the centroid and the points would all be in the same TIN structure allowing fast find of neighbors.
     101}}}
    98102 * Might be very inefficient and a waste of computing TIN in case there is only one point in the source table (Constraint 1) or there are very small number of source points and the requested raster is relatively small too (Constraint 5).
    99 
     103[[BR]][[BR]]
    100104==== 3. The KNN index approach ====
    101105
    102 The third approach is similar to the second but use the new KNN indexing facilities of PostGIS to determine the nearest neighbor points of each pixel.
     106  The third approach is similar to the second but use the new KNN indexing facilities of PostGIS to determine the nearest neighbor points of each pixel.
    103107
    104        
    105         CREATE FUNCTION euclidean_fct(raster rast, text dbschema, text sourcetable, text sourcegeomcolumn)
     108{{{
     109#!sql   
     110CREATE FUNCTION euclidean_fct(raster rast, text dbschema, text sourcetable, text sourcegeomcolumn)
    106111RETURNS float
    107112AS $$
     
    119124SELECT rid, ST_MapalgebraFct(rast, 'euclidean_fct(rast, dbschema, sourcetable, sourcegeomcolumn)'::regprocedure) rast
    120125FROM myexistingcoveragetable
     126}}}
    121127
    122         Pros:
    123 ○       Source points do not have to be in the raster extent (constraint 4)
    124 ○       Should work well  with large number of source points (constraint 1, 5c & 5d) since we will be using KNN index to find the nearest point.
    125 ○       Make it possible to to createa tiled raster coverage aligned to an existing one (constraint 3)
    126 ○       Opening to be able to reused for further computing interpolation since the method to find neighbors is quite generic.
    127         Cons:
    128 ○       Might not be as light as Approach 1 in case there is only one point in the source table (Constraint 1) or there are very small number of source points and the requested raster is relatively small too (Constraint 5)
    129 ○       Have no idea how to deal with Constraint 9.
     128'''Pros:'''
     129 * Source points do not have to be in the raster extent (constraint 4)
     130 * Should work well  with large number of source points (constraint 1, 5c & 5d) since we will be using KNN index to find the nearest point.
     131 * Make it possible to to createa tiled raster coverage aligned to an existing one (constraint 3)
     132 * Opening to be able to reused for further computing interpolation since the method to find neighbors is quite generic.
    130133
     134'''Cons:'''
     135 * Might not be as light as Approach 1 in case there is only one point in the source table (Constraint 1) or there are very small number of source points and the requested raster is relatively small too (Constraint 5)
     136 * Have no idea how to deal with Constraint 9.
    131137
     138[[BR]][[BR]]
    132139==== Preferred Approach ====
    133140
    134141Approach 3 is the preferred approach for the following reasons:
    135 ●       it exploits and benefits from a very unique and performant new feature of PostGIS: KNN indexing,
    136 ●       it is compliant with PostGIS Raster powerful raster/vector interactions
    137 ●       in terms of scalability, it provides the possibility to generate a distance raster from any coverage of point (however numerous they are) since the time to find the nearest neighbor for each pixel is relatively constant (thanks to the KNN index),
    138 ●       it makes it possible to work with huge tiled coverage (constraint 3) since the extent of the raster is independent of the source extent,
    139 ●       it provides a reusable approach for other types of distances (Constraint 13) and interpolation.
     142 * It exploits and benefits from a very unique and performant new feature of PostGIS: KNN indexing,
     143 * It is compliant with PostGIS Raster powerful raster/vector interactions
     144 * In terms of scalability, it provides the possibility to generate a distance raster from any coverage of point (however numerous they are) since the time to find the nearest neighbor for each pixel is relatively constant (thanks to the KNN index),
     145 * It makes it possible to work with huge tiled coverage (constraint 3) since the extent of the raster is independent of the source extent,
     146 * It provides a reusable approach for other types of distances (Constraint 13) and interpolation.
    140147
    141 
     148[[BR]][[BR]]
    142149==== Tentative functions signatures: ====
    143150
    144 Generate a raster having the same alignment as a reference raster:
     151  Generate a raster having the same alignment as a reference raster:
    145152
     153{{{
     154#!c
    146155ST_EuclideanDistance(raster ref, text sourceschema, text sourcetable, text sourcegeomcolumn, text pixeltype, double precision value=1, double precision nodataval=0)
     156}}}
    147157
    148 Generate a raster based on raster specifications:
     158  Generate a raster based on raster specifications:
    149159
    150 ●       Set the dimensions of the raster by providing the parameters of a pixel size (scalex & scaley and skewx & skewy). The width & height of the resulting raster will be adjusted to fit the extent of the geometry
     160 * Set the dimensions of the raster by providing the parameters of a pixel size (scalex & scaley and skewx & skewy). The width & height of the resulting raster will be adjusted to fit the extent of the geometry
     161{{{
     162#!c
     163ST_EuclideanDistance(text dbschema, text sourcetable, text sourcegeomcolumn, double precision scalex, double precision scaley, double precision gridx, double precision gridy, text pixeltype, double precision value=1, double precision nodataval=0, double precision skewx=0, double precision skewy=0)
     164}}}
    151165
    152 ST_EuclideanDistance(text dbschema, text sourcetable, text sourcegeomcolumn, double precision scalex, double precision scaley, double precision gridx, double precision gridy, text pixeltype, double precision value=1, double precision nodataval=0, double precision skewx=0, double precision skewy=0)
     166 * Fix the dimensions of the raster by providing the dimensions of the raster (width & height). The parameters of the pixel size (scalex & scaley and skewx & skewy) of the resulting raster will be adjusted to fit the extent of the source geometry
     167{{{
     168#!c
     169ST_EuclideanDistance(text dbschema, text sourcetable, text sourcegeomcolumn, geometry geom, integer width, integer height, double precision gridx, double precision gridy, text pixeltype, double precision value=1, double precision nodataval=0, double precision skewx=0, double precision skewy=0)
     170}}}
    153171
    154 ●       Fix the dimensions of the raster by providing the dimensions of the raster (width & height). The parameters of the pixel size (scalex & scaley and skewx & skewy) of the resulting raster will be adjusted to fit the extent of the source geometry
    155 
    156 ST_EuclideanDistance(text dbschema, text sourcetable, text sourcegeomcolumn, geometry geom, integer width, integer height, double precision gridx, double precision gridy, text pixeltype, double precision value=1, double precision nodataval=0, double precision skewx=0, double precision skewy=0)
    157 
    158  
    159 For Constraint 6: (just write down the function that takes a reference raster for example)
     172 * For Constraint 6: (just write down the function that takes a reference raster for example)
     173{{{
     174#!c
    160175ST_EuclideanDistance(text dbschema, text sourcetable, text sourcegeomcolumn, raster ref, text pixeltype, double precision value=1, double precision nodataval=0, double precision maxdistance)
     176}}}