Hi Pierre,<br>I am trying to compute the "actual distances" in meters before creating the raster and then re-project it back to SRID 4326.<br><br>-- Trying to now get the Top left point of raster<br>SELECT ST_X(ST_Transform(ST_SetSRID(ST_Point(8.07734039737749, 57.7505109647578),4326),32632)),<br>
ST_Y(ST_Transform(ST_SetSRID(ST_Point(8.07734039737749, 57.7505109647578),4326),32632));<br><br><br>-- Width <br>select ceil(ST_X(ST_Transform(ST_SetSRID(ST_Point(15.1919565742587, 57.7505109647578),4326),32632)) -<br>
ST_X(ST_Transform(ST_SetSRID(ST_Point(8.07734039737749, 57.7505109647578),4326),32632)));<br><br>-- Height<br>select ceil(ST_Y(ST_Transform(ST_SetSRID(ST_Point(8.07734039737749, 57.7505109647578),4326),32632)) -<br> ST_Y(ST_Transform(ST_SetSRID(ST_Point(8.07734039737749, 54.4984986588244),4326),32632)));<br>
<br>I have now made it a multiple of 4 so now I will get height = 361932 and width = 423152<br><br>Is this ok? Once I have made the raster, I can then transform it back to srid 4326 before doing PixelAsPolygons right?<br>
<br>Cheers,<br>Ed<br><br><br><div class="gmail_quote">On Fri, Mar 23, 2012 at 1:55 PM, Pierre Racine <span dir="ltr"><<a href="mailto:Pierre.Racine@sbf.ulaval.ca">Pierre.Racine@sbf.ulaval.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">> Can you please let me know how I can do this? So I did the make empty raster -><br>
> map algebra -> pixel as polygons approach!<br>
> Since there is no dependency on data now, is it possible for you to maybe<br>
> outline the steps you performed at your end to get this working?<br>
> MapAlgebra needed 2 rasters, so I inputted the same raster twice. So please<br>
<br>
</div>There is a one raster version of ST_MapAlgebraExpr(). That's the one to use....<br>
<div class="im"><br>
> --SELECT (md).*<br>
> --FROM (SELECT ST_MetaData(rast) As md<br>
> -- FROM (select ST_MakeEmptyRaster( 8, 4, 8.07734039737749,<br>
> 57.7505109647578, 0.000036,0.000036,0,0, 4326 ) rast) foo) foo2;<br>
><br>
><br>
> create table vector_grid as<br>
> select (ST_PixelAsPolygons(rastfin)).geom , (ST_PixelAsPolygons(rastfin)).val<br>
> from ( select ST_MapAlgebraExpr(rast, rast, '([rast.x] - 1) * ' ||<br>
> ST_Width(rast)::text || ' + [rast.y]' ) rastfin from (select ST_MakeEmptyRaster( 8,<br>
> 4, 8.07734039737749, 57.7505109647578, 0.000036,0.000036,0,0, 4326 ) rast)<br>
> foo) foo2;<br>
<br>
</div>If you want to assign the index values to the raster:<br>
<br>
SELECT ST_MapAlgebraExpr(ST_MakeEmptyRaster(8, 4, 8.07734039737749, 57.7505109647578, 0.000036,0.000036,0,0, 4326 ), '32BUI', '([rast.x] - 1) * 8 + [rast.y]'::text)<br>
<br>
If you are happy with the polygons:<br>
<br>
SELECT (gvxy).geom, ((gvxy).x - 1) + (gvxy).y cellid<br>
FROM (SELECT ST_PixelAsPolygons(ST_MakeEmptyRaster(8, 4, 8.07734039737749, 57.7505109647578, 0.000036,0.000036,0,0, 4326 )) gvxy) foo<br>
<span class="HOEnZb"><font color="#888888"><br>
Pierre<br>
<br>
<br>
</font></span></blockquote></div><br>