Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to update my table with the values from a raster stored within the database.

Edit: I've posted the answer bellow: http://gis.stackexchange.com/a/63655/6711

The query I'm trying to use is Q

update data.points_test_10000 
    set sdi_index = (
            select 
                st_value(rast,geom)  from 
                    rasters.sdi_4326 a,    
                    data.points_test_10000 b 
                where 
                    a.rast && b.geom
                    ) ;

but I'm getting the error:

more than one row returned by a subquery used as an expression

without the set statments the query works as it should

share|improve this question

2 Answers 2

Perhaps like this:

UPDATE data.points_test_10000 
    SET sdi_index = (
            SELECT 
                st_value(a,b.geom)  from 
                    rasters.sdi_4326 a,    
                    data.points_test_10000 b 
                WHERE 
                    (a.rast && b.geom) 
                    AND (b.id = data.points_test_10000.id) 
                    ) ;
share|improve this answer
    
no, unfortunately it gives the same error –  nickves Jun 16 '13 at 18:15
up vote 0 down vote accepted

Use ST_Intersects to limit per entry

UPDATE data.points_test_10000 p SET sdi_index = 
    ST_value(r.rast,p.geom) 
        from 
            rasters.sdi_4326 r 
        where 
            ST_Intersects(p.geom,r.rast)
;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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