<div dir="ltr">Hi,<br>I have a raster file and a vector file. I want to assign to each
pixel in my raster size a value derived from the vector file (which are
polygons). To do this, I want to test that the centroid of my pixel
lies within a given polygon. In the past, I have done this
gdal_rasterize-ing the polygon file, and going through numpy arrays. It
is a bit cumbersome, and the rasterization is not really needed with
OGR. However, it seems that if my pixel centroid is (x,y), I will need
to go through all features in my layer, extract the geometry and do a
Contains() test for my (x,y) point. I can cut the number of iterations
(I guess, not tried) by using a SpatialFilter on my vector layer, so
only one (ish) geometry is returned, so I would only need to do one
Contains test (I do have a _lot_ of polygons in this file)<br>
<br>Is there some other (better) way of doing this? I'm using the python ogr bindings.<br><br>Thanks!<br>Jose<br clear="all"><br>-- <br>Centre for Terrestrial Carbon Dynamics<br>Department of Geography, University College London<br>
Gower Street, London WC1E 6BT, UK<br>
</div>