Distance rule that filtering a set of points in "ppp" class by minimum or maximum distance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Distance rule that filtering a set of points in "ppp" class by minimum or maximum distance

R-sig-geo mailing list
Dear R-Sig_Geo Members,

I'd like to find a more simple way to filtering a set of points in a
"ppp" object by minimum or maximum distance.

In my example using a ants ("ppp" object) in spatstat package:

#Packages
library(spatstat)
library(sp)

#Point process example
data(ants)
str(ants)
#- attr(*, "class")= chr "ppp"

#Computes the matrix of distances between all pairs of ants nests and
selection of more than 20 m distance neighborhood
ants.df<-as.data.frame(ants)
coordinates(ants.df) <- ~x+y
ants.dmat <- spDists(ants.df) #Calculate a distance matrix using spDists
min.dist <- 20 #distance range
ants.dmat[ants.dmat <= min.dist] <- NA # Na for less than 20 meters

Here yet I need to start a relative long code for identified columns
with NA in ants.dmat object, create a new data frame and than create a
new ppp object based in the coordinates and marks etc...

Is there any more easy way for create a new "ppp" object just only
specified a distance rule that filtering a set of points in a original
"ppp" object by minimum or maximum distance?

Thanks in advanced,

Alexandre

--
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/1360403201088680
OrcID: 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
Reply | Threaded
Open this post in threaded view
|

Re: c884

Andrew Bevan
I am on leave until mid-December 2020 and will only be checking emails very intermittently.

If you are a prospective student and have queries about the MSc in Computational Archaeology, please email Mark Lake ([hidden email]).

On 28 Aug 2020, at 02:17, ASANTOS via R-sig-Geo <[hidden email]> wrote:

Dear R-Sig_Geo Members,

I'd like to find a more simple way to filtering a set of points in a
"ppp" object by minimum or maximum distance.

In my example using a ants ("ppp" object) in spatstat package:

#Packages
library(spatstat)
library(sp)

#Point process example
data(ants)
str(ants)
#- attr(*, "class")= chr "ppp"

#Computes the matrix of distances between all pairs of ants nests and
selection of more than 20 m distance neighborhood
ants.df<-as.data.frame(ants)
coordinates(ants.df) <- ~x+y
ants.dmat <- spDists(ants.df) #Calculate a distance matrix using spDists
min.dist <- 20 #distance range
ants.dmat[ants.dmat <= min.dist] <- NA # Na for less than 20 meters

Here yet I need to start a relative long code for identified columns
with NA in ants.dmat object, create a new data frame and than create a
new ppp object based in the coordinates and marks etc...

Is there any more easy way for create a new "ppp" object just only
specified a distance rule that filtering a set of points in a original
"ppp" object by minimum or maximum distance?

Thanks in advanced,

Alexandre

--
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: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flattes.cnpq.br%2F1360403201088680&amp;data=02%7C01%7C%7Ca70f07e55bbb49d60ec008d84af0479d%7C1faf88fea9984c5b93c9210a11d9a5c2%7C0%7C0%7C637341743158107956&amp;sdata=yE4%2Fk76Ya9lntZoXFJsAUHg55rl%2BBVLBHuFk95Q4uc8%3D&amp;reserved=0
OrcID: orcid.org/0000-0001-8232-6722
ResearchGate: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.researchgate.net%2Fprofile%2FAlexandre_Santos10&amp;data=02%7C01%7C%7Ca70f07e55bbb49d60ec008d84af0479d%7C1faf88fea9984c5b93c9210a11d9a5c2%7C0%7C0%7C637341743158107956&amp;sdata=hLw2XYvqjhMn%2FuJOXmYu%2BHUKrLFgrZaxoSj6%2Bl%2BIm6Q%3D&amp;reserved=0
Publons: https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublons.com%2Fresearcher%2F3085587%2Falexandre-dos-santos%2F&amp;data=02%7C01%7C%7Ca70f07e55bbb49d60ec008d84af0479d%7C1faf88fea9984c5b93c9210a11d9a5c2%7C0%7C0%7C637341743158107956&amp;sdata=o%2FR75Akr9VE%2BF6GLEWHcEsbRtoRkLCkjsBk%2BXH%2F5yLc%3D&amp;reserved=0
--


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&amp;data=02%7C01%7C%7Ca70f07e55bbb49d60ec008d84af0479d%7C1faf88fea9984c5b93c9210a11d9a5c2%7C0%7C0%7C637341743158107956&amp;sdata=%2Fhi%2Fkda%2FniyJ0GuRmnZvoBPl92%2BwmORhGcZFNShiNRc%3D&amp;reserved=0

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Distance rule that filtering a set of points in "ppp" class by minimum or maximum distance

Rolf Turner
In reply to this post by R-sig-geo mailing list

On Thu, 27 Aug 2020 21:17:58 -0400
ASANTOS via R-sig-Geo <[hidden email]> wrote:

> Dear R-Sig_Geo Members,
>
> I'd like to find a more simple way to filtering a set of points in a
> "ppp" object by minimum or maximum distance.
>
> In my example using a ants ("ppp" object) in spatstat package:
>
> #Packages
> library(spatstat)
> library(sp)
>
> #Point process example
> data(ants)
> str(ants)
> #- attr(*, "class")= chr "ppp"
>
> #Computes the matrix of distances between all pairs of ants nests and
> selection of more than 20 m distance neighborhood
> ants.df<-as.data.frame(ants)
> coordinates(ants.df) <- ~x+y
> ants.dmat <- spDists(ants.df) #Calculate a distance matrix using
> spDists min.dist <- 20 #distance range
> ants.dmat[ants.dmat <= min.dist] <- NA # Na for less than 20 meters
>
> Here yet I need to start a relative long code for identified columns
> with NA in ants.dmat object, create a new data frame and than create
> a new ppp object based in the coordinates and marks etc...
>
> Is there any more easy way for create a new "ppp" object just only
> specified a distance rule that filtering a set of points in a
> original "ppp" object by minimum or maximum distance?
>
> Thanks in advanced,
>
> Alexandre
>

It's very easy! :-)

ddd <- nndist(ants)
farAnts <- ants[ddd >= 20]

cheers,

Rolf

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo