0

Trying to intersect two rasters, but they don't have the same scale. I have to do everything in one query.

The query below gets the following error: The two rasters provided do not have the same alignment

select row_to_json(t) from (
    SELECT A.rid, B.rid, pvc
    FROM file_xbwnbydpmwesokzmrcht A 
    JOIN file_caolvkddzzlgmvyeofrh B 
    ON ST_Intersects(A.rast, B.rast), 
       ST_ValueCount(ST_Intersection(A.rast,1, B.rast, 1)) AS pvc
) as t;

I've tried this, but syntax is wrong, apparently (ERROR: column a.rast does not exist):

select row_to_json(t) from (
    SELECT A.rid, B.rid, pvc
    FROM (
        select st_rescale(
            C.rast, st_scalex(D.rast)
        ) from file_caolvkddzzlgmvyeofrh as C CROSS JOIN file_xbwnbydpmwesokzmrcht as D
    ) as A
    JOIN file_caolvkddzzlgmvyeofrh B 
    ON ST_Intersects(A.rast, B.rast), 
       ST_ValueCount(ST_Intersection(A.rast,1, B.rast, 1)) AS pvc
) as t;

How can I do this?

  • I think you need to alias the function call ST_Rescale(....) as rast, as this is what a.rast will be referring to. At the moment, it will have the alias st_rescale. – John Powell Jun 1 '16 at 12:50
  • Thanks @JohnBarça. Could you provide a full example from what I have above? – knutole Jun 1 '16 at 17:30

Your Answer

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

Browse other questions tagged or ask your own question.