 		             quote_literal('8BUI')||'::text), ST_SRID(rast)) as rast ' ||
             'FROM ' || quote_ident(gt_schema)||'.'||quote_ident(rast_table)||') empty_rast_750 ' ||
       'WHERE ST_Intersects(a.geom_nlcd, b.rast) AND ' ||
-                    'ST_Intersects(c.geom, b.rast) AND ' || 
 	            dist_clause ||
 	            'b.rid = empty_rast_750.rid AND ' ||
 	            'pixel_size = 750  ' ||

	EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(schema) || '.fire_events_raster' ;
	
	IF distance <> -1 THEN 
	  dist_clause := 'ST_DWithin(a.geom_nlcd, c.geom, $1) AND ';
          filter_tbl := ', '||quote_ident(gt_schema)||'.'||quote_ident(geom_table)||' c ' ;
	ELSE
	  dist_clause := ' ' ;

    CREATE TEMPORARY TABLE newrasters (rid integer, rast_750 raster) ; 
    
    IF distance <> -1 THEN 
        dist_clause := 'ST_DWithin(a.geom_nlcd, c.geom, $1) AND ' ||
                       'ST_Intersects(c.geom, b.rast) AND ' ;
        filter_tbl := quote_ident(gt_schema)||'.'||quote_ident(geom_table)||' c, ' ;
    ELSE
        dist_clause := ' ' ;
