185795 (4) [Avatar] Offline
#1
I hope the the authors still watch this forum...Im running into this issue.

When I run:

INSERT INTO ch07.bag_o_rasters(rast_name, rast)  
WITH a1 AS (SELECT ST_Buffer(ST_GeomFromText('LINESTRING(448252 5414206,448289 5414317,448293 5414330,448324 5414417,448351 5414495)', 32631),10) As geom)
SELECT 'disprop road', ST_AsRaster(geom,50,500) FROM a1
UNION ALL
SELECT 'proport fixed w road', 
    ST_AsRaster(geom,200,(
        (ST_YMax(geom) - ST_YMin(geom)) *  200 / 
        (ST_XMax(geom) - ST_XMin(geom)))::integer 
FROM a1;


I get:

ERROR:  syntax error at or near "FROM"
LINE 9: FROM a1;
        ^
********** Error **********

ERROR: syntax error at or near "FROM"
SQL state: 42601
Character: 432
regina.leo (253) [Avatar] Offline
#2
Sorry about that. Misplaced paretheses it seems. Try this:

WITH a1 AS (SELECT ST_Buffer(ST_GeomFromText('LINESTRING(448252 5414206,448289 5414317,448293 5414330,448324 5414417,448351 5414495)', 32631),10) 
    As geom)

	SELECT 'disprop road', ST_AsRaster(geom,50,500) FROM a1
	UNION ALL

	SELECT 'proport fixed w road',

	    ST_AsRaster( geom, 200, 

	        ( ST_YMax(geom) - ST_YMin(geom) ) *  200 /

	        ( ST_XMax(geom) - ST_XMin(geom)  )::integer)
	FROM a1;