Hi.  I am desperate for advice on a very simple problem.

 

I’ve got an out-of-db raster table that contains a time-series of images of a 
large area (one image per date), and it is tiled. It’s about 20,000 rows in all 
and I’m trying to clip it with a polygon so that I get back a smaller raster.  
If I union the tiles for any particular date and then clip them, I get the 
answer that I expect.  Without the union, the clip doesn’t work as expected, 
and I don’t understand why.  I’ll show this in two steps for simplicity:

 

#1. Create a unioned raster of 32 tiles to create a single image for a 
particular date:

  CREATE TABLE onedate AS (

    SELECT ST_Union(rast) AS rast FROM myrastertable

    WHERE image_date = '2010-01-01'

  )

 

#2. Clip the unioned raster with a polygon (gives the correct answer):

  SELECT ST_Clip(rast, geom,true) AS rast FROM onedate, my_polygon)

 

…but if I try the same thing without the union, it gives the wrong answer:

 

#3. Select the 32 tiles for the same date 

  CREATE TABLE onedate_tiled AS (

    SELECT * FROM myrastertable WHERE image_date = '2010-01-01'

  )

 

#4. Clip the tiled raster (this fails: it seems to get rid of some of the tiles 
where there is no overlap with the polygon, but stuff hangs over the edges of 
the polygon for tiles that lie across the boundary of the polygon)

  SELECT ST_Clip(rast, geom, true) AS rast FROM onedate_tiled, my_polygon

  WHERE ST_Intersects(rast, geom)

 

I’d love to know what I am missing.  Ultimately, I want to clip all of the 
dates to the same polygon.

 

Thanks!

 

John

_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to