Thank you, Sebastiano. That worked for me. Cheers, PauloFR
Às 06:32 de 10/11/2021, Sebastiano Trevisani escreveu: > 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_ > > */ > /* > /IUAV University of Venice: // > /* > /www.iuav.it <http://www.iuav.it/>/ > */ > / > *// > Address: Dorsoduro 2206, Venice 30123, Italy > /Tel: +39. 041. 257 1299/ > /Mail: strevis...@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.m...@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@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo