1

I want to clip raster (SRID 32649) with polygon(SRID 4326) into SRID 32648

First I transform raster using query

create view ras68 as
select st_transform(rast,32648) as rast
from ras69

Then cutting raster 32648 with polygon

select st_union(st_clip(rast,1,st_transform(geom,32648),true) )
from ras68, shp
where st_intersects(rast,st_transform(geom,32648))

The result has error:

ERROR: rt_raster_from_two_rasters: The two rasters provided do not have the same alignment ********** Error **********

ERROR: rt_raster_from_two_rasters: The two rasters provided do not have the same alignment SQL state: XX000

What's my mistake and how to fix that ? (If run st_intersects() only, the result are fine, they overlap)

2

You need to do your st_transform of raster aligned to a reference raster otherwise each tile gets its own scale etc. so may no longer match up.

Try:

   CREATE OR REPLACE VIEW ras68 as
      WITH ref AS (
       SELECT ST_Transform(rast,32648) As rast_alignto
           FROM ras69 LIMIT 1)
      SELECT st_transform(rast,rast_alignto) as rast
      FROM ras69;

and then rerun your union

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.