[postgis-users] Problem with union of rasters (postgis 2.4 rds)

Lionel Cayla lionelcayla at yahoo.se
Thu Jun 4 12:51:07 PDT 2020


 Hi Regina, 
Thanks for your message, that's a good tip indeed and I will use from now on; but that wasn't the problem. 
The problem was that since I was in wgs84 (4326), the scale factor would not let me see the geometries. After putting scaleX and scaleY to 0.00000227 it did the trick. 
Thanks in any case, 
-Lionel
    Le mercredi 3 juin 2020 à 06:10:57 UTC+2, Regina Obe <lr at pcorp.us> a écrit :  
 
 
ST_AsRaster has a ton of overloaded formats unfortunately.  I suspect your 

  

SELECT ST_ASRaster(ST_SetSRID(ST_EXTENT( myQuads), 4326), 0.1, 0.1 ,'8BUI')

  

Is falling into the overload

  

raster ST_AsRaster(geometry geom, integer width, integer height, text pixeltype, double precision value=1, double precision nodataval=0, double precision upperleftx=NULL, double precision upperlefty=NULL, double precision skewx=0, double precision skewy=0, boolean touched=false);

  

Instead of raster ST_AsRaster(geometry geom, double precision scalex, double precision scaley, text pixeltype, double precision value=1, double precision nodataval=0, double precision upperleftx=NULL, double precision upperlefty=NULL, double precision skewx=0, double precision skewy=0, boolean touched=false);

  

Try explicitly specifying the args

  

SELECT ST_ASRaster(ST_SetSRID(ST_EXTENT( myQuads), 4326), scalex => 0.1, scaley => 0.1 , pixeltype => '8BUI')

  

  

For older versions of PostgreSQL, you might need to replace the =>  with :=

  

Hope that helps,

Regina

  

  

From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Lionel Cayla
Sent: Tuesday, June 2, 2020 9:17 AM
To: postgis-users at lists.osgeo.org
Subject: [postgis-users] Problem with union of rasters (postgis 2.4 rds)

  

Hi, 

  

I am having an issue, when rasterizing a union of rasters. Each of the geometries from my initial table are quads or polygons, and the following SQL command 

(that should work according the documentation right?) gives me a raster 2x2 .

  

CREATE TABLE raster_test AS

(WITH

rast AS (SELECT ST_ASRaster(ST_SetSRID(ST_EXTENT( myQuads), 4326), 0.1, 0.1 ,'8BUI')

FROM myDB, 

WHERE ST_IsValid(myQuads)),

  raster_ AS (SELECT ST_Union(ST_ASRaster(ST_SetSRID(ST_Force2D( myQuads), 4326), rast.ST_ASRaster), 'SUM')

FROM myDB, rast

WHERE myQuads  IS NOT NULL)

 SELECT  raster_.ST_Union as rast_chunks

  FROM raster_, rast );

  

The command produces the desired raster if I replace my resolution (0.1, 0.1) by the raster size if it's equal to 150. Over that (200 say) I get an alignment error message.

I tried to cast 0.1 to double precision I still get an issue. 

  

I am wondering if I am doing something wrong here or if there's a known issue. 

  

Thanks, 

  

-Lio
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200604/a909764a/attachment.html>


More information about the postgis-users mailing list