[postgis-devel] [PostGIS] #1176: [raster] Two raster ST_Intersects
PostGIS
trac at osgeo.org
Mon Sep 12 13:50:01 PDT 2011
#1176: [raster] Two raster ST_Intersects
----------------------------+-----------------------------------------------
Reporter: dustymugs | Owner: dustymugs
Type: enhancement | Status: assigned
Priority: medium | Milestone: PostGIS 2.0.0
Component: postgis raster | Version: trunk
Keywords: |
----------------------------+-----------------------------------------------
Comment(by bnordgren):
Oh my. That seems complicated. May I offer an alternative algorithm which
should mean less operations per pixel? It may be too simple or not cover a
use case, so please blast away at it. It's pseudocode so holler out if
anything is unclear.
{{{
if (A.SRID != B.SRID) return false;
grid_overlaps := convex hull of A overlaps convex hull of B.
if (no bands have been provided) {
return grid_overlaps;
} else {
if (not grid_overlaps) return false ;
smaller := A or B, depending on which raster has fewer pixels;
big := the other raster
for smaller_j := 1,small_HEIGHT {
for smaller_i := 1, small_WIDTH {
(big_i, big_j) = big_geopoint2cell(small_cell2geopoint(smaller_i,
smaller_j))
if ( 0 < big_i <= big_WIDTH) AND (0 < big_j <= big_HEIGHT) {
round big_i and big_j to nearest integer indices ;
if (big_getValue(big_i, big_j) != NODATA) {
return TRUE ;
}
}
}
}
}
return FALSE ;
}}}
This could address the special case where one raster fits completely
within one cell of the other if we make sure that the selection of
"smaller" does not allow the pixelsize of "smaller" to be larger than the
whole "bigger" raster.
So maybe the criteria for "smaller" would be "which raster has the minimum
pixel size", and if there's a tie: "which raster has fewer pixels"?
Note, I implemented the rt_raster_geopoint_to_cell(), offloaded both
forward and backwards transformations to GDAL, and made sure the code uses
the accessor methods instead of the fields here:
https://github.com/bnordgren/postgis/commit/ab632411b303aca898c285c53e428060ea9e35de
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1176#comment:7>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-devel
mailing list