[postgis-devel] [postgis-users] How to handle tiled rasters (ST_Value, grid_pt=>coord, coord=>grid_pt etc)?

Paragon Corporation lr at pcorp.us
Sat Dec 11 09:20:13 PST 2010


Hmm slight correction  I spoke too soon about the whole grid thing.  I
think you have to take the whole extent of the table then divide by the
width and height of the extent by the ST_Width and ST_Height to get numbers
of tiles in each original grid row.
Sounds very messy and more than I can think of at the moment.  

Again not sure what the utility of that is even when you are rendering on a
map since you would be rendering tiles that intersect with your area of
interest using ST_Intersects.

 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Paragon
Corporation
Sent: Saturday, December 11, 2010 11:51 AM
To: 'PostGIS Users Discussion'; 'Stefan Keller'
Cc: 'PostGIS Development Discussion'
Subject: Re: [postgis-users] How to handle tiled rasters
(ST_Value,grid_pt=>coord, coord=>grid_pt etc)?

Stefan,

Slight addition to what I said in response to this question


> Query 4: Given one real projected coordinate (e.g. 489500/102500) 
> return
the corresponding ("closest") grid point and its value.
> => ?  

What do you mean by grid point ? Again no concept when you are talking about
a tiled raster at least in PostGIS Raster unles you multiply by the number
of rows in the table etc.



The value would be

SELECT rid,  ST_Value(rast, 1, g.pt) As pixvalband1,
ST_World2RasterX(rast,pt) As x, ST_World2RasterY(rast,pt) As y FROM
ch1000_tif_tiles INNER JOIN 
	(SELECT ST_GeomFromText('POINT(489500 102500)', 21781)  As pt) As g 
   ON ST_Intersects(rast,  g.pt );

Note the x and y are for that given tile.  If you want the position across
the whole grid and you have regular gridding and you imported using
raster2pgsql, then you would use something like

(rid - 1)*ST_Width(rast) + ST_World2RasterX(rast,pt) As x,  (rid -
1)*ST_Height(rast) + ST_World2RasterY(rast,pt) As y

Relevant links here
http://www.postgis.org/documentation/manual-svn/RT_ST_World2RasterCoordX.htm
l
http://www.postgis.org/documentation/manual-svn/RT_ST_World2RasterCoordY.htm
l
http://www.postgis.org/documentation/manual-svn/RT_ST_Width.html
http://www.postgis.org/documentation/manual-svn/RT_ST_Height.html

I'm curious though -- which use cases do you have where you need the grid x,
y from the original raster?


Hope that  helps,
Regina
http://www.postgis.us



_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-devel mailing list