Changes between Version 156 and Version 157 of WKTRaster/SpecificationWorking03


Ignore:
Timestamp:
Sep 22, 2011, 8:18:10 AM (13 years ago)
Author:
Bborie Park
Comment:

ST_Intersects

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking03

    v156 v157  
    2424 
    2525
    26 '''ST_Intersects(raster, raster)'''[[BR]]
    27 
    28 This function uses the same tests as the two geometry version of ST_Intersects where tests see if two rasters overlap, touches or has one within the other.  If any condition is true, the two rasters intersect.
    29 
    30 For this description, the rasters are called A and B and the bands tested are assumed to be 1.
    31 
    32 Preliminary criteria before the real work begins:
    33 
    34 1. make sure that rasters A and B have the same SRID.  if not, return false.
    35 
    36 2. make sure that the convex hulls of A and B intersect.  if not, return false.
    37 
    38 Special case where a raster may be fully contained within another raster's cell (the entirety of A within a cell of B):
    39 
    40 1. using every third pixel by row and column, test each selected cell's geopoint (excluding no data by default unless exclude_nodata_value = FALSE) of A to that of B for overlap.
    41 
    42 2. if a cell of A does overlap a cell of B, return true.
    43 
    44 3. if no cell of A overlaps with B, continue to additional testing
    45 
    46 Actual testing involves the use of calculating the intersection of grid lines between A and B
    47 
    48 1. Using every third A's column and B's row, calculate the intersection point of each pair of grid lines.
    49 
    50 2. If intersection point doesn't exist or is outside the bounds of the end points comprising each grid line used, go back to step 1.
    51 
    52 3. If intersection point exists and within bounds, sample the area around the intersection point by offset the intersection point by a small amount (1/10th of the smaller scale of A and B) for 360 degrees starting from 00:00.  sampled points are 0, 45, 90, 135, 180, 225, 270 and 315 degrees.
    53 
    54 4. At each sample point, test to see if the geopoint has non-nodata (unless including nodata) values in both A and B.  if so, return true.
    55 
    56 5. At the same time as step 4, build an adjacency matrix for the intersection to see if two non-overlapping pixels from A and B touch.
    57 
    58 6. Once all sample points have been tested and no overlapping pixels found, the adjacency matrix is checked to see if any sampled pixel of A touched a sampled pixel of B.  If two pixels touched, return true.
    59 
    60 7. If after all the searching and testing, nothing intersects or touches, return false.
    61 
    62 A set of ST_Intersects functions for rasters:
    63 
    64 1. ST_Intersects(raster rastA, raster rastB, integer bandA DEFAULT NULL, integer bandB DEFAULT NULL) -> boolean
    65 
    66 If bandA and bandB are NULL, only the convex hulls of the rasters will be tested.  If bandA or bandB are provided, both parameters must be provided and not NULL.
    67 
    68 2. ST_Intersects(raster rastA, integer bandA, raster rastB, integer bandB) -> boolean
    69 
    70 A refactored set of St_Intersects() for testing a raster and a geometry.  The first set converts the geometry to a raster to see if the two rasters intersect.
    71 
    72 3. ST_Intersects(rast raster, geom geometry, nband integer DEFAULT NULL) -> boolean
    73 
    74 4. ST_Intersects(rast raster, nband integer, geom geometry) -> boolean
    75 
    76 The second set of ST_Intersects() for testing a raster and a geometry converts the raster to a geometry and sees if the geometries intersect.
    77 
    78 5. ST_Intersects(geom geometry, rast raster, nband DEFAULT NULL) -> boolean
    79 
    80 The order in which the geometry and raster are passed into ST_Intersects determines which method of testing is used.  If geometry is first, the raster is converted to a set of geometries.  If raster is first, the geometry is converted to a raster.
    81 
    82 These set of functions are required because there are cases where ST_Intersects(raster, geometry) != ST_Intersects(geometry, raster).
    83 
    84 [[Image(st_intersects_triangle.png)]]
    85 
    86 In the image above, the black border denotes the boundary of a triangle polygon and the red within is the raster version of the geometry.  The polygon touches the raster in blue while the red raster does not.
     26'''ST_Intersects(raster, raster) -> boolean - done see below'''[[BR]]
    8727
    8828'''ST_AsRaster(geometry, pixeltype, val, nodataval, ulx, uly, width, height, pixelsizex, pixelsizey, skewx, skewy) -> raster - done see below'''
     
    12441184== '''Objective FV.02 - Being able to intersect vector and raster to produce raster.''' ==
    12451185
     1186'''ST_Intersects(raster, raster) -> boolean'''[[BR]]
     1187
     1188This function uses the same tests as the two geometry version of ST_Intersects where tests see if two rasters overlap, touches or has one within the other.  If any condition is true, the two rasters intersect.
     1189
     1190For this description, the rasters are called A and B and the bands tested are assumed to be 1.
     1191
     1192Preliminary criteria before the real work begins:
     1193
     11941. make sure that rasters A and B have the same SRID.  if not, return false.
     1195
     11962. make sure that the convex hulls of A and B intersect.  if not, return false.
     1197
     1198Special case where a raster may be fully contained within another raster's cell (the entirety of A within a cell of B):
     1199
     12001. using every third pixel by row and column, test each selected cell's geopoint (excluding no data by default unless exclude_nodata_value = FALSE) of A to that of B for overlap.
     1201
     12022. if a cell of A does overlap a cell of B, return true.
     1203
     12043. if no cell of A overlaps with B, continue to additional testing
     1205
     1206Actual testing involves the use of calculating the intersection of grid lines between A and B
     1207
     12081. Using every third A's column and B's row, calculate the intersection point of each pair of grid lines.
     1209
     12102. If intersection point doesn't exist or is outside the bounds of the end points comprising each grid line used, go back to step 1.
     1211
     12123. If intersection point exists and within bounds, sample the area around the intersection point by offset the intersection point by a small amount (1/10th of the smaller scale of A and B) for 360 degrees starting from 00:00.  sampled points are 0, 45, 90, 135, 180, 225, 270 and 315 degrees.
     1213
     12144. At each sample point, test to see if the geopoint has non-nodata (unless including nodata) values in both A and B.  if so, return true.
     1215
     12165. At the same time as step 4, build an adjacency matrix for the intersection to see if two non-overlapping pixels from A and B touch.
     1217
     12186. Once all sample points have been tested and no overlapping pixels found, the adjacency matrix is checked to see if any sampled pixel of A touched a sampled pixel of B.  If two pixels touched, return true.
     1219
     12207. If after all the searching and testing, nothing intersects or touches, return false.
     1221
     1222A set of ST_Intersects functions for rasters:
     1223
     12241. ST_Intersects(raster rastA, raster rastB, integer bandA DEFAULT NULL, integer bandB DEFAULT NULL) -> boolean
     1225
     1226If bandA and bandB are NULL, only the convex hulls of the rasters will be tested.  If bandA or bandB are provided, both parameters must be provided and not NULL.
     1227
     12282. ST_Intersects(raster rastA, integer bandA, raster rastB, integer bandB) -> boolean
     1229
     1230A refactored set of St_Intersects() for testing a raster and a geometry.  The first set converts the geometry to a raster to see if the two rasters intersect.
     1231
     12323. ST_Intersects(rast raster, geom geometry, nband integer DEFAULT NULL) -> boolean
     1233
     12344. ST_Intersects(rast raster, nband integer, geom geometry) -> boolean
     1235
     1236The second set of ST_Intersects() for testing a raster and a geometry converts the raster to a geometry and sees if the geometries intersect.
     1237
     12385. ST_Intersects(geom geometry, rast raster, nband DEFAULT NULL) -> boolean
     1239
     1240The order in which the geometry and raster are passed into ST_Intersects determines which method of testing is used.  If geometry is first, the raster is converted to a set of geometries.  If raster is first, the geometry is converted to a raster.
     1241
     1242These set of functions are required because there are cases where ST_Intersects(raster, geometry) != ST_Intersects(geometry, raster).
     1243
     1244[[Image(st_intersects_triangle.png)]]
     1245
     1246In the image above, the black border denotes the boundary of a triangle polygon and the red within is the raster version of the geometry.  The polygon touches the raster in blue while the red raster does not.
     1247
    12461248'''ST_AsRaster(geometry, pixeltype, val, nodataval, ulx, uly, width, height, pixelsizex, pixelsizey, skewx, skewy) -> raster'''
    12471249