[gdal-dev] Raster/vector intersections in PostGIS WKT Raster

Jorge Arévalo jorge.arevalo at deimos-space.com
Tue Jun 29 13:45:51 EDT 2010


Hello,

On Tue, Jun 29, 2010 at 6:46 PM,  <christian.mueller at nvoe.at> wrote:
> Hi, superb job. Congratulations.
>
> I am a geotools/geoserver developer and one of my jobs is fetching image
> tiles  or the corresponding pyramid tiles from jdbc data sources. Some weeks
> ago, I added support for Oracle Georaster and I want to support WKT
> Georaster too.
>
> wktraster makes it quite simple to achieve this. Is there any database
> layout you recommend. (A table for the image and one for each pyramid, or
> put all the tiles into one table having an attribute "level",.....).
>

I'd recommend one table for each separate tiled image. That's, in
fact, one of the ways WKT Raster works, in terms of raster table
arrangement.


> I have seen "gdal2wktraster.py", is this the recommended way to import tiles
> into postgis ?

Yes, this is the way you should use now to import images into PostGIS.

And related with pyramids, if you provide "-l <OVERVIEW_LEVEL>" as
command line option, you will get overview tables named as
o_<LEVEL>_<RASTER_TABLE> and will be populated with GDAL-provided
overviews. Only regular blocking arrangements (see "-k" command line
option too). If you use this "-l" command line option, you'll have to
specify "-V" option too, only the first time you call the script. This
option enables the creation of the needed RASTER_OVERVIEWS table.

Oh, and the gdal2wktraster script generates a SQL output. You'll have
to load into your raster-ready schema.

> What is the table layout created/needed by this utility ?
>
You'll simply need to "raster-enable" your PostGIS schema by executing
rt_pg/rtpostgis.sql, after compiling and installing WKT Raster. One
additional table, named "RASTER_COLUMNS", will be created in your
schema.

As I said above, if you use "-V" option the first time you execute the
loader script (gdal2wktraster), another new table, named
"RASTER_OVERVIEWS" will be created in your schema too.

This is all you need to start :-)

Comments are welcome, as Pierre said.

> Cheers
> Christian
>
>
>
> Quoting Pierre Racine <Pierre.Racine at sbf.ulaval.ca>:
>
>> Hi everybody,
>>
>> I'm pleased to announce that you can now do intersections between  rasters
>> and geometries very much like you used to do  geometry/geometry
>> intersections in PostGIS. For this, PostGIS WKT  Raster introduces two new
>> functions to PostGIS:  ST_Intersects(geometry, raster, band) and
>> ST_Intersection(geometry,  raster, band).
>>
>> As its geometry/geometry sister, ST_Intersects(geometry, raster,  band)
>> returns TRUE if the withvalue area of a raster or a raster  tile (nodata
>> value are ignored) intersects a geometry and  ST_Intersection(geometry,
>> raster, band) returns the geometry/value  set of geometries representing the
>> intersection between the geometry  and each polygonized group of pixel
>> sharing a same value from the  raster and its associated value. Example:
>>
>> SELECT polyid,
>>       (ST_Intersection(the_geom, rast)).geom,
>>       (ST_Intersection(the_geom, rast)).val
>> FROM my_polygons, srtm_tiled
>> WHERE ST_Intersects(rast, the_geom)
>>
>> or, a bit more complex, but much faster and returning the same result:
>>
>> SELECT polyid, (gv).geom, (gv).val
>> FROM (SELECT polyid, ST_Intersection(the_geom, rast, 1) AS gv
>>     FROM my_polygons, srtm_tiled
>>     WHERE ST_Intersects(rast, the_geom)) foo
>>
>> These functions works with any kind of geometry so you can intersect  any
>> road, river, polygons or point layer with your favorite  elevation or land
>> cover raster of any resolution and any size. You  can also load any number
>> of raster in the database with one command  line to constitute a unique
>> table raster coverage of any shape (no  matter if your group of raster do
>> not form a rectangular coverage).
>>
>> You will find a complete tutorial on how to use those two new  functions
>> here:  http://trac.osgeo.org/postgis/wiki/WKTRasterTutorial01. A reference
>>  is available here:
>>  http://postgis.refractions.net/documentation/manual-svn/RT_reference.html
>>  and chapter 13 of "PostGIS in Action" is also a very good  introduction to
>> WKT Raster.
>>
>> Compilation and installation info are available in the project home  page:
>> http://trac.osgeo.org/postgis/wiki/WKTRaster
>>
>> These features are the result of two years of collaboration between  many
>> people and companies interested in bringing raster into  PostGIS. I would
>> like to thanks particularly Steve Cumming who  initially made all this
>> possible, Sandro Santilli who wrote the base  code, Mateusz Loskot who wrote
>> the Python loader, Jorge Arevalo who  wrote the GDAL driver and
>> ST_DumpAsPolygons(), Regina and Leo Obe  who are doing so many things and
>> believed in the project from the  beginning by adding a chapter about WKT
>> Raster in "PostGIS in  Action" and also David Zwarg who wrote most of the
>> setter functions.
>>
>> This is the first step toward a first complete raster/vector  analysis and
>> manipulation SQL API. We hope to make of PostGIS with  WKT Raster the most
>> powerful and complete GIS analysis and  manipulation high level language
>> ever (!!!). WKT Raster should  normally be totally integrated into PostGIS
>> in PostGIS release 2.0.  Upcoming functions should include ST_Reclass,
>> ST_Clip, ST_AsRaster,  ST_Resample.
>>
>> Let us know your need and your experience with WKT Raster.
>>
>> Thanks,
>>
>> Pierre Racine
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Jorge Arévalo
DEIMOS Space
Internet & Mobilty Division
Ronda de Poniente 19. Edificio Fiteni VI, portal 2, 2º
28760 Tres Cantos (Madrid)
Tel: +34 91 806 34 50 - ext: 155
jorge.arevalo at deimos-space.com
http://gis4free.wordpress.com


More information about the gdal-dev mailing list