# Filtering a set of points in a "ppp" object by distance using marks

5 messages
Open this post in threaded view
|

## Filtering a set of points in a "ppp" object by distance using marks

 Dear R-Sig-Geo Members, I'd like to find any way to filtering a set of points in a "ppp" object by minimum distance just only between different marks. In my example: #Package library(spatstat) #Point process example - ants data(ants) ants.ppp<-ppp(x=ants\$x,y=ants\$y,marks=rep("antNests",length(ants\$x)),window=Window(ants)) # Create a artificial point pattern - termites termites <- rpoispp(0.0005, win=Window(ants)) termites.ppp<-ppp(x=termites\$x,y=termites\$y,marks=rep("termiNests",length(termites\$x)),window=Window(ants)) #Join ants.ppp and termites.ppp insects.ppp<-superimpose(ants.ppp,termites.ppp) #If I try to use subset function: subset(insects.ppp, pairdist(insects.ppp) > 20 & marks=="termiNests") #Marked planar point pattern: 223 points #marks are of storage type �character� #window: polygonal boundary #enclosing rectangle: [-25, 803] x [-49, 717] units (one unit = 0.5 feet) #Warning message: #In ppp(X[, 1], X[, 2], window = win, marks = marx, check = check) : # 70751 out of 70974 points had NA or NaN coordinate values, and were discarded Not the desirable result yet, because I'd like to calculate just only the > 20 "termiNests" to "antNests" marks and not the "termiNests" with "termiNests" too. Please any ideas? Thanks in advanced, -- Alexandre dos Santos Geotechnologies and Spatial Statistics applied to Forest Entomology Instituto Federal de Mato Grosso (IFMT) - Campus Caceres Caixa Postal 244 (PO Box) Avenida dos Ramires, s/n - Vila Real Caceres - MT - CEP 78201-380 (ZIP code) Phone: (+55) 65 99686-6970 / (+55) 65 3221-2674 Lattes CV: http://lattes.cnpq.br/1360403201088680OrcID: orcid.org/0000-0001-8232-6722 ResearchGate: www.researchgate.net/profile/Alexandre_Santos10 Publons: https://publons.com/researcher/3085587/alexandre-dos-santos/--         [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Open this post in threaded view
|

## Re: Filtering a set of points in a "ppp" object by distance using marks

 Hi Alexandre, may be this? ddd <- nndist(insects.ppp, by=factor(insects.ppp\$marks)) subset(insects.ppp,  marks=="termiNests" & ddd[,"termiNests"] >20) Cheers, Marcelino El 15/09/2020 a las 22:52, ASANTOS via R-sig-Geo escribió: > Dear R-Sig-Geo Members, > > I'd like to find any way to filtering a set of points in a "ppp" object by minimum distance just only between different marks. In my example: > > #Package > library(spatstat) > > #Point process example - ants > data(ants) > ants.ppp<-ppp(x=ants\$x,y=ants\$y,marks=rep("antNests",length(ants\$x)),window=Window(ants)) > > > # Create a artificial point pattern - termites > termites <- rpoispp(0.0005, win=Window(ants)) > termites.ppp<-ppp(x=termites\$x,y=termites\$y,marks=rep("termiNests",length(termites\$x)),window=Window(ants)) > > > #Join ants.ppp and termites.ppp > insects.ppp<-superimpose(ants.ppp,termites.ppp) > > > #If I try to use subset function: > > subset(insects.ppp, pairdist(insects.ppp) > 20 & marks=="termiNests") > > #Marked planar point pattern: 223 points #marks are of storage type > �character� #window: polygonal boundary #enclosing rectangle: [-25, 803] > x [-49, 717] units (one unit = 0.5 feet) #Warning message: #In ppp(X[, > 1], X[, 2], window = win, marks = marx, check = check) : # 70751 out of > 70974 points had NA or NaN coordinate values, and were discarded > > Not the desirable result yet, because I'd like to calculate just only the > 20 "termiNests" to "antNests" marks and not the "termiNests" with "termiNests" too. > > Please any ideas? > > Thanks in advanced, > -- Marcelino de la Cruz Rot Depto. de Biología y Geología Física y Química Inorgánica Universidad Rey Juan Carlos Móstoles España _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Open this post in threaded view
|

## Re: Filtering a set of points in a "ppp" object by distance using marks

 Sorry, I meant to say subset(insects.ppp, marks=="termiNests" & ddd[,"antNests"] >20) El 16/09/2020 a las 9:18, Marcelino de la Cruz Rot escribió: > Hi Alexandre, > > may be this? > > > ddd <- nndist(insects.ppp, by=factor(insects.ppp\$marks)) > subset(insects.ppp,  marks=="termiNests" & ddd[,"termiNests"] >20) > > > Cheers, > > Marcelino > > > El 15/09/2020 a las 22:52, ASANTOS via R-sig-Geo escribió: >> Dear R-Sig-Geo Members, >> >> I'd like to find any way to filtering a set of points in a "ppp" >> object by minimum distance just only between different marks. In my >> example: >> >> #Package >> library(spatstat) >> >> #Point process example - ants >> data(ants) >> ants.ppp<-ppp(x=ants\$x,y=ants\$y,marks=rep("antNests",length(ants\$x)),window=Window(ants)) >> >> >> >> # Create a artificial point pattern - termites >> termites <- rpoispp(0.0005, win=Window(ants)) >> termites.ppp<-ppp(x=termites\$x,y=termites\$y,marks=rep("termiNests",length(termites\$x)),window=Window(ants)) >> >> >> >> #Join ants.ppp and termites.ppp >> insects.ppp<-superimpose(ants.ppp,termites.ppp) >> >> >> #If I try to use subset function: >> >> subset(insects.ppp, pairdist(insects.ppp) > 20 & marks=="termiNests") >> >> #Marked planar point pattern: 223 points #marks are of storage type >> �character� #window: polygonal boundary #enclosing rectangle: [-25, 803] >> x [-49, 717] units (one unit = 0.5 feet) #Warning message: #In ppp(X[, >> 1], X[, 2], window = win, marks = marx, check = check) : # 70751 out of >> 70974 points had NA or NaN coordinate values, and were discarded >> >> Not the desirable result yet, because I'd like to calculate just only >> the > 20 "termiNests" to "antNests" marks and not the "termiNests" >> with "termiNests" too. >> >> Please any ideas? >> >> Thanks in advanced, >> > -- Marcelino de la Cruz Rot Depto. de Biología y Geología Física y Química Inorgánica Universidad Rey Juan Carlos Móstoles España _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo