[postgis-users] Geom/Rast Intersection St9bad_alloc

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Tue Apr 24 11:27:06 PDT 2012


James,

Sorry for this late answer.

-What is the type of the geometries you are intersecting with the raster? 

-If they are polygons, what proportion of your raster does all your geometry layer represent? 

If this proportion is very high (your polygons cover like 90% of the raster extent and your raster are big) then you are better to compute the summary stat in raster space like this:

SELECT (ST_SummaryStatsAgg(ST_Clip(rast, geom))).*
FROM clip_build, nclheat
WHERE ST_Intersects(rast, geom)

ST_SummaryStatsAgg is not installed with PostGIS 2.0. You will find here:

http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_summarystatsagg.sql

In this case your tiles should be about the same size of the average size of your polygons.

If the area covered by your polygons or if those geometries are lines you might instead do the process in vector space and do like you did using ST_AreaWeightedSummaryStats.sql

http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_areaweightedsummarystats.sql

In this case smaller tiles are always better (10x10).

The result of ST_Intersection is vectors and it is done on one band at a time. If you want a three band raster as a result then maybe you want to ST_Clip instead.

Pierre

> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-
> bounces at postgis.refractions.net] On Behalf Of JamesH
> Sent: Tuesday, April 24, 2012 11:42 AM
> To: postgis-users at postgis.refractions.net
> Subject: Re: [postgis-users] Geom/Rast Intersection St9bad_alloc
> 
> "I am attempting to intersect a vector dataset of building polygons with a
> 3-Band Thermal tiff to produce a dataset that shows the thermal readings for
> each polygon."
> 
> If I took the 3 band jpeg of this raster and used ST_AsTiff to convert it to
> a single band tiff would this calculation be valid? How could I place this
> into the query?
> 
> SELECT gid, ST_Intersection(geom, rast, 1)
> FROM clip_build, nclheat
> WHERE ST_Intersects(rast, geom)
> 
> any help greatly appreciated,
> 
> Kind Regards,
> James
> 
> -----
> GIS Undergraduate
> --
> View this message in context: http://postgis.17.n6.nabble.com/Geom-Rast-
> Intersection-St9bad-alloc-tp4912994p4913835.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list