On 9/8/05, <b class="gmail_sendername">Glynn Clements</b> <<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> What is the simplest way to get get a singular cell in a raster map to be<br>> set to a value,<br>> irregardless of the current regions resolution?<br>><br>> More specifically I want to set closest cell to the origin (0,0) to have
<br>> value 1. But only 1 cell must be present, and it must work for any<br>> resolution - although I'm currently concerned with working at res=1.<br><br>This is awkward if two or four cells are all an equal distance from
<br>the origin. If you ignore that case, you're after the cell which is<br>less than half the grid resolution from the origin in each direction,<br>e.g.:<br><br> out = abs(x()) < ewres()/2 && abs(y()) < nsres()/2
</blockquote><div><br>
Thanks Glynn for clarifying that for me.<br>
<br>
I actually realised that I was making a conceptual mistake in
thinking there was a center cell for [0,0], when the origin is
actually a coordinate rather than a cell! (I thinking I just needed to
sleep on it ;)<br>
<br>
The way I now get around this is to use the above equation (similar to
what I was already doing but I was having trouble with cells
equidistant from the origin), and then add 0.5 to the x and y
coordinates - thus selecting the cell just to the right and above the
origin.<br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> I've been playing with mapcalc but the way it calculates x() and y() seems<br>
> odd and round() rounds them to either 1 or -1, skipping 0. int() truncates<br>> leaving two rows/columns with a value 0.<br><br>round() rounds towards the nearest integer, so:<br><br> round( 0.7) == 1<br> round(
0.2) == 0<br> round(-0.2) == 0<br> round(-0.7) == -1<br><br>etc.<br><br>int() rounds towards zero, so:<br><br> int( 1.2) == 1<br> int( 0.9) == 0<br> int(-0.9) == 0<br> int(-1.2
) == -1<br><br></blockquote></div><br>
Thats what I thought they should do, I realise that when I was using
round the coordinates were > 0.5 or < -0.5 thus round would give
1.<br>
<br>
Thanks,<br>
Joel<br>