[postgis-users] PostGIS Raster and Overviews

Francois Hugues hugues.francois at irstea.fr
Mon Jan 28 13:58:22 PST 2013


Hello,
 
I'm not sure to understand everything about what you are trying to do, but if i'm not wrong, you try to rasterize some geometries. I'm not sure that's the better way to work, but i don't really know how your data looks like.
 
Anyaway, it seems to me you're misunderstanding about rasters and bands. The first one is a regular grid of pixels, and the second is a kind of layer. For example, a RGB image is a three bands raster.
 
As far as i understand your problem, it seems to me that you need only a one raster band where you should add all your points' values with st_MakeEmptyRaster (setting properly the origin - upperleft corner X and Y- , extent and pixel size to match your points spatial distribution), then add a band and finally you should be able to set pixels values using st_SetValue with st_MakePoint to make a geometry from your long/lat coordinates.
 
If you want to use spatial index on raster, it should be better to tile it first with st_Tile (available since postgis 2.1)
 
Hugues.
 

________________________________

From: postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of Mikel Gonzalez
Sent: Monday, January 28, 2013 3:35 PM
To: postgis-users at lists.osgeo.org
Subject: [postgis-users] PostGIS Raster and Overviews


Hi all!

I'm quite new to PostGIS but I think I'm learning rather quickly. Anyways, I have a question regarding the storage of raster data in PostGIS. First of all, I think the raster2psql utility is wondrous and works great but unfortunately some of the data I need to store as a raster comes to me in text format. Let's say I have the latitude/longitude values and then the value of the raster in that point which in this case, it'll be the swell.

Thing is I've been loading this data to postGIS without any major complication and then publishing that same info through geoserver. Let me show you how I load the data to PostGIS:

First,


	create table <tableName> (rid SERIAL primary key, rast raster)
	
	

Then, for every row of data, 
   


	insert into <tableName> (rast) select ST_AddBand(ST_MakeEmptyRaster(1,1,<long>, <lat>,1,1,0,0,4326), 1, '32BF', %s, 0.0)
	

And,


	CREATE INDEX myrasters_rast_st_convexhull_idx ON <tableName> USING gist( ST_ConvexHull(rast) );
	SELECT AddRasterConstraints('<tableName>'::name, 'rast'::name);
	


This is all done in a python script and stores the data (I think) correctly. I've got to admit that I still need to understand a little bit more some of the parameters that are passed to the AddBand and MakeEmptyRaster functions, but I can do it in my own, this is not why I'm writing to you. The reason in fact, is that even though GeoServer does show the data, it takes quite a lot to load, and I thought it might be because I have not defined any overviews. I've been trying to find how to do it, but all I see is references to the raster2psql utility, but since I'm also a little new with Python I don't know exactly what it does.

So, after all this, my question would be how can I add overviews "manually" to this raster data I'm loading? I would even appreciate if you can tell me where in raster2psql.py I can find it, or if it is in any other file it's being used for that purpose.

Thank you very much for reading and I hope I was clear enough about my issue :-)


-- 
--

Mikel Gonzalez Gainza,
Informatikari bekaduna CENER-en // Becario informático en CENER
www.cener.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130128/0d2bd346/attachment.html>


More information about the postgis-users mailing list