[R-sig-Geo] Identify specific pixel neighbours

Sebastiano Trevisani @trev|@@n| @end|ng |rom |u@v@|t
Wed Nov 10 07:32:48 CET 2021


Hi Paulo,

you could use a focal analysis approach using the "terra" package. You
could build for each category (e.g., "urban", "forest", etc)
a raster with an indicator coding (1 and 0) and then apply simple kernel
(weight matrix, as below) doing the summation of the neighboring pixels.

1 1 1
1 NA 1
1 1 1

If the resulting pixel (at the center of the kernel) is >0 means that one
of the neighboring pixels is of the considered category.

But maybe there are specialized packages doing directly this.

Sincerely,

Sebastiano


*      Sebastiano Trevisani, Ph.D.*
*            Associate Professor*
*Applied and Environmental Geology*


*  https://orcid.org/0000-0001-8436-7798
<https://orcid.org/0000-0001-8436-7798>*
*IUAV University of Venice: www.iuav.it <http://www.iuav.it/>*

*Address: Dorsoduro 2206,  Venice 30123, Italy Tel:    +39. 041. 257
1299Mail:    strevisani using iuav.it <strevisani using iuav.it> *
*"Le opinioni espresse sono riferibili esclusivamente all'autore e non *
* riflettono in alcun modo una posizione ufficiale dello IUAV "*
*"The views expressed are purely those of the writer and may not in
any circumstances be regarded as stating an official position of the IUAV."*


On Tue, Nov 9, 2021 at 6:40 PM Paulo Flores Ribeiro <
paulo.flores.mail using gmail.com> wrote:

> I would like to create a raster from an existing one, where each pixel
> in the new raster is set to 1 if the corresponding pixel in the existing
> map is in the direct neighbourhood (8 neighbouring pixels) of at least 1
> pixel with a particular value, or 0 if otherwise (e.g., create a raster
> that identifies all "agricultural" pixels that are neighbours of "urban"
> pixels). How to do this in the most computationally efficient way?
> Thanks in advance, PauloFR
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list