[postgis-devel] PostGIS Raster

Jorge Arévalo jorge.arevalo at deimos-space.com
Tue Dec 21 03:26:24 PST 2010


On Tue, Dec 21, 2010 at 10:10 AM, cesius <emilio.detorres at fueca.es> wrote:
>
> Hello,
>
> I have to develop an application where it's necessary to find the satellite
> image (GeoTIFF) which a point, given its lat-long, belongs to.
>
> Can PostGIS Raster do a query of this kind? How coul I do it? I have find
> the ST_Envelope function but it returns the four corners of a rectangle and
> my images are no regular polygons.
>
> Thank you very much.
> --
> View this message in context: http://old.nabble.com/PostGIS-Raster-tp30471969p30471969.html
> Sent from the PostGIS - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel
>

Hello,

You can try this:

0.- Create a PostGIS Raster-enabled database. Check this:
http://postgis.refractions.net/documentation/manual-svn/RT_FAQ.html#id3022293

1.- Load each GeoTiff file in a different table (assuming you want to
identify the concrete GeoTiff file each point belongs to)

raster2pgsql -r /path/to/raster/file.tif -t table1 -s <file_srid> -l 1
-M -I -o file1.sql [-k widthxheight]
psql -U your_user -W -d your_database -f file1.sql

The "-k" option is useful if your GeoTiff files are big. In that case,
the GeoTiff file will be tiled and each tile will be stored in a
table's row. If you don't specify it, the whole raster file will be
loaded in only one table's row.

Repit this step with each GeoTiff file, changing the name of the
table. You can store all the GeoTiff files in one table, but in that
case, you wouldn't know what was the original GeoTiff file each point
belongs to (not in an easy way, at least)

2.- Use ST_World2RasterCoordX, ST_World2RasterCoordY functions
(http://postgis.refractions.net/documentation/manual-svn/RT_ST_World2RasterCoordX.html,
http://postgis.refractions.net/documentation/manual-svn/RT_ST_World2RasterCoordY).html
with each point and each table. A PL/pgSQL script may help you to
automate this process.

Hope it works...

Best regards,

-- 
Jorge Arévalo
Internet & Mobilty Division, DEIMOS
jorge.arevalo at deimos-space.com
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com
http://geohash.org/ezjqgrgzz0g



More information about the postgis-devel mailing list