[R-sig-Geo] Distance from point to specified raster cell value

Matt Strimas-Mackey strimas at zoology.ubc.ca
Mon Jul 6 20:57:20 CEST 2015


Perhaps the rasterToPoints function is what you're after:
http://www.inside-r.org/packages/cran/raster/docs/rasterToPoints

 gDistance(spatialpoints, rasterToPoints(r, fun=function(x) {x == 15}))

On Mon, Jul 6, 2015 at 10:38 AM, Alexandre Lafontaine
<a_lafontaine at hotmail.com> wrote:
>
> Dear members,
> I am looking for a way to extract the distance from spatial points objects to the closest raster cell of a specific value. I have not a found a way to do so yet with the raster or rgeos librairies...
>
> Something like the gDistance function in which I could specify the raster value I am interested in:
>
>
>          gDistance( spatialpoints, r[r==15])
>
>
> If anyone have suggestions, (it needs to be fairly quick because I have thousands of points to compute).
>
>
> Any help really appreciated,
>
>
> Alex Lafontaine
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list