[R-sig-Geo] Extract from raster produces NA when polygon has holes

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Dec 16 16:29:59 CET 2014


On Tue, Dec 16, 2014 at 3:07 PM, Brooks E.G.E. <Emma.Brooks at soton.ac.uk> wrote:
> Dear all
>
> I am using extract to 'extract' the values from raster to polygons, which is working fine until I noticed a couple of values are coming up as NA. On closer inspection these polygons have holes; it is a lake layer so these are representing islands. I don't know why expressly the extract function doesn't like holes - is there any way round this, or do I need to manually remove these? (I don't want to remove them as ideally I don't want to extract the data which belongs to the islands rather than the lakes).
>
> I am thinking this may be obvious for people in the know, but if it needs clarifying, or dummy data, apologies and please let me know.

 I think we need dummy data.... I would expect NA where there is a
hole, since extract doesn't know what the right value is there. If you
want to get the value of the surrounding polygon when extracting at a
hole then you'll have to remove the holes and just use the outer
polygon, assuming you only have one outer polygon...

 However, if you are getting NA all over any polygon that does have a
hole somewhere then I wonder if your polygons are coded the right way
round....

 Barry



More information about the R-sig-Geo mailing list