Clipping raster without create a new table in PostGIS

المشرف العام

Administrator
طاقم الإدارة
I'm learning about PostGIS, and I would like to create a SQL to cut a raster with a shapefile to work in my R program. I managed creating a new table, but I would like build it without a new table.

I'm executing this code to create table (its working):

SELECT ST_Union(ST_Clip(raster.rast, ST_Transform(polygon.geom, ST_SRID(raster.rast) ) ) ) as rast FROM originalraster as raster, originalshape as polygon WHERE ST_Intersects(raster.rast, polygon.geom) I managed execute this code, to return a 'Gtiff', but the output of my R is: Error in .local(x, ...) : list has no "x".

SELECT ST_AsGDALRaster(rast, 'GTiff') FROM (SELECT ST_Union(ST_Clip(raster.rast, ST_Transform(polygon.geom, ST_SRID(raster.rast) ) ) ) as rast FROM originalraster as raster, originalshape as polygon WHERE ST_Intersects(raster.rast, polygon.geom)) AS rast; I had this problem before, and executing the PostGIS function AddRasterConstraints in my table it was solved. I couldn't execute this function in my SQL.

I saw in others posts that generally the way used for this, is creating a new table or view on SQL, but I wouldn't like to make this.

Best regards, Thanks



أكثر...
 
أعلى