Re: [R-sig-Geo] Help

2020-01-09 Thread Bakary Faty
Thanks very much angain,
 I'll check them out.

Best regards

Le jeu. 9 janv. 2020 à 19:05, Ben Tupper  a écrit :

> Your assignments that look like...
>
> minx <-  rain_data_UTM at bbox[1,1]
>
> are not valid R statements - and that will cause an error.  Instead,
> obtain a matrix of the bounding box using the bbox() function.  Then
> extract your coordinates from that. I think you want...
>
> bb <- bbox(rain_data_UTM)
> minx <- bb[1,1]
> maxx <- bb[1,2]
> miny <- bb[2,1]
> maxy <- bb[2,2]
>
> If you haven't seen this, https://www.rspatial.org/ , it is well worth
> your time.  There are a lot of other great resources about using spatial
> data in R.  Try searching the Rseek.org. Like this
> https://rseek.org/?q=spatial+tutorials  It is a gold mine.
>
>
> On Thu, Jan 9, 2020 at 1:42 PM Bakary Faty  wrote:
>
>> Thank you for appreciated reply,
>>
>> I explane you exactly what I want to do with this R code attached.
>> I want to adapt this code to my data to build an isohyet map.
>> But i have some difficulties to adapt it to my case.
>> I will be very happy when you will help my to adapt this R code (attached)
>> to my case.
>> You can find attached the you R code, my data file and my sahefile of
>> watershed.
>>
>> Best regards
>>
>>
>> Le jeu. 9 janv. 2020 à 17:47, Ben Tupper  a écrit :
>>
>>> Welcome to r-sig-geo!
>>>
>>> I don't think that you haven't provided us enough information so that we
>>> can help.  On the other hand, does the example below using expand.grid help?
>>>
>>> minx <- 20
>>> maxx <- 25
>>> miny <- 31
>>> maxy <- 36
>>> pixel <- 1
>>> grd <- expand.grid(x = seq(minx, maxx, by=pixel), y = seq(miny, maxy,
>>> by=pixel))
>>>
>>> Ben
>>>
>>> On Thu, Jan 9, 2020 at 11:41 AM Bakary Faty 
>>> wrote:
>>>

 Dear,

 I'm writing to express my wish to join R-sig-geo list users.
 I was doing a search on the net to know how to build an isohyet map and
 I came across this R code.
 However, I stumbled upon a problem from the line :
 grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
 by=pixel)),
 I get the following error message:
 default method not implemented for type 'S4'. I want to know how
 resolve this error.

 Also, I would like to ask you only at the line level:
 minx <- rain_data_UTM at bbox[1,1]
 maxx <- rain_data_UTM at bbox[1,2]
 miny <- rain_data_UTM at bbox[2,1]
 maxy <- rain_data_UTM at bbox[2,2],
 if I should limit myself to "rain_data_UTM" or write completely:
 rain_data_UTM at bbox[,].
  By the way, this is the pointfile I reconstructed.
 You can find it attached to the mail.

 Thanks in advance

 Best regards



 Bakary
 ___
 R-sig-Geo mailing list
 R-sig-Geo@r-project.org
 https://stat.ethz.ch/mailman/listinfo/r-sig-geo

>>>
>>>
>>> --
>>> Ben Tupper
>>> Bigelow Laboratory for Ocean Science
>>> West Boothbay Harbor, Maine
>>> http://www.bigelow.org/
>>> https://eco.bigelow.org
>>>
>>>
>>
>> --
>>
>>
>>
>> Bakary
>>
>
>
> --
> Ben Tupper
> Bigelow Laboratory for Ocean Science
> West Boothbay Harbor, Maine
> http://www.bigelow.org/
> https://eco.bigelow.org
>
>

-- 



Bakary

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Help

2020-01-09 Thread Ben Tupper
Your assignments that look like...

minx <-  rain_data_UTM at bbox[1,1]

are not valid R statements - and that will cause an error.  Instead,
obtain a matrix of the bounding box using the bbox() function.  Then
extract your coordinates from that. I think you want...

bb <- bbox(rain_data_UTM)
minx <- bb[1,1]
maxx <- bb[1,2]
miny <- bb[2,1]
maxy <- bb[2,2]

If you haven't seen this, https://www.rspatial.org/ , it is well worth your
time.  There are a lot of other great resources about using spatial data in
R.  Try searching the Rseek.org. Like this
https://rseek.org/?q=spatial+tutorials  It is a gold mine.


On Thu, Jan 9, 2020 at 1:42 PM Bakary Faty  wrote:

> Thank you for appreciated reply,
>
> I explane you exactly what I want to do with this R code attached.
> I want to adapt this code to my data to build an isohyet map.
> But i have some difficulties to adapt it to my case.
> I will be very happy when you will help my to adapt this R code (attached)
> to my case.
> You can find attached the you R code, my data file and my sahefile of
> watershed.
>
> Best regards
>
>
> Le jeu. 9 janv. 2020 à 17:47, Ben Tupper  a écrit :
>
>> Welcome to r-sig-geo!
>>
>> I don't think that you haven't provided us enough information so that we
>> can help.  On the other hand, does the example below using expand.grid help?
>>
>> minx <- 20
>> maxx <- 25
>> miny <- 31
>> maxy <- 36
>> pixel <- 1
>> grd <- expand.grid(x = seq(minx, maxx, by=pixel), y = seq(miny, maxy,
>> by=pixel))
>>
>> Ben
>>
>> On Thu, Jan 9, 2020 at 11:41 AM Bakary Faty  wrote:
>>
>>>
>>> Dear,
>>>
>>> I'm writing to express my wish to join R-sig-geo list users.
>>> I was doing a search on the net to know how to build an isohyet map and
>>> I came across this R code.
>>> However, I stumbled upon a problem from the line :
>>> grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
>>> by=pixel)),
>>> I get the following error message:
>>> default method not implemented for type 'S4'. I want to know how resolve
>>> this error.
>>>
>>> Also, I would like to ask you only at the line level:
>>> minx <- rain_data_UTM at bbox[1,1]
>>> maxx <- rain_data_UTM at bbox[1,2]
>>> miny <- rain_data_UTM at bbox[2,1]
>>> maxy <- rain_data_UTM at bbox[2,2],
>>> if I should limit myself to "rain_data_UTM" or write completely:
>>> rain_data_UTM at bbox[,].
>>>  By the way, this is the pointfile I reconstructed.
>>> You can find it attached to the mail.
>>>
>>> Thanks in advance
>>>
>>> Best regards
>>>
>>>
>>>
>>> Bakary
>>> ___
>>> R-sig-Geo mailing list
>>> R-sig-Geo@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>>
>> --
>> Ben Tupper
>> Bigelow Laboratory for Ocean Science
>> West Boothbay Harbor, Maine
>> http://www.bigelow.org/
>> https://eco.bigelow.org
>>
>>
>
> --
>
>
>
> Bakary
>


-- 
Ben Tupper
Bigelow Laboratory for Ocean Science
West Boothbay Harbor, Maine
http://www.bigelow.org/
https://eco.bigelow.org

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Help

2020-01-09 Thread Bakary Faty
Thank you for appreciated reply,

I explane you exactly what I want to do with this R code attached.
I want to adapt this code to my data to build an isohyet map.
But i have some difficulties to adapt it to my case.
I will be very happy when you will help my to adapt this R code (attached)
to my case.
You can find attached the you R code and my data file.
Best regards

Le jeu. 9 janv. 2020 à 18:41, Bakary Faty  a écrit :

> Thank you for appreciated reply,
>
> I explane you exactly what I want to do with this R code attached.
> I want to adapt this code to my data to build an isohyet map.
> But i have some difficulties to adapt it to my case.
> I will be very happy when you will help my to adapt this R code (attached)
> to my case.
> You can find attached the you R code, my data file and my sahefile of
> watershed.
>
> Best regards
>
>
> Le jeu. 9 janv. 2020 à 17:47, Ben Tupper  a écrit :
>
>> Welcome to r-sig-geo!
>>
>> I don't think that you haven't provided us enough information so that we
>> can help.  On the other hand, does the example below using expand.grid help?
>>
>> minx <- 20
>> maxx <- 25
>> miny <- 31
>> maxy <- 36
>> pixel <- 1
>> grd <- expand.grid(x = seq(minx, maxx, by=pixel), y = seq(miny, maxy,
>> by=pixel))
>>
>> Ben
>>
>> On Thu, Jan 9, 2020 at 11:41 AM Bakary Faty  wrote:
>>
>>>
>>> Dear,
>>>
>>> I'm writing to express my wish to join R-sig-geo list users.
>>> I was doing a search on the net to know how to build an isohyet map and
>>> I came across this R code.
>>> However, I stumbled upon a problem from the line :
>>> grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
>>> by=pixel)),
>>> I get the following error message:
>>> default method not implemented for type 'S4'. I want to know how resolve
>>> this error.
>>>
>>> Also, I would like to ask you only at the line level:
>>> minx <- rain_data_UTM at bbox[1,1]
>>> maxx <- rain_data_UTM at bbox[1,2]
>>> miny <- rain_data_UTM at bbox[2,1]
>>> maxy <- rain_data_UTM at bbox[2,2],
>>> if I should limit myself to "rain_data_UTM" or write completely:
>>> rain_data_UTM at bbox[,].
>>>  By the way, this is the pointfile I reconstructed.
>>> You can find it attached to the mail.
>>>
>>> Thanks in advance
>>>
>>> Best regards
>>>
>>>
>>>
>>> Bakary
>>> ___
>>> R-sig-Geo mailing list
>>> R-sig-Geo@r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>>
>> --
>> Ben Tupper
>> Bigelow Laboratory for Ocean Science
>> West Boothbay Harbor, Maine
>> http://www.bigelow.org/
>> https://eco.bigelow.org
>>
>>
>
> --
>
>
>
> Bakary
>


-- 



Bakary


DATAFILE_FOR_ISOHYET.csv
Description: MS-Excel spreadsheet


R_code_for_rainfall_isohyet_map.R
Description: Binary data
___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Help

2020-01-09 Thread Ben Tupper
Welcome to r-sig-geo!

I don't think that you haven't provided us enough information so that we
can help.  On the other hand, does the example below using expand.grid help?

minx <- 20
maxx <- 25
miny <- 31
maxy <- 36
pixel <- 1
grd <- expand.grid(x = seq(minx, maxx, by=pixel), y = seq(miny, maxy,
by=pixel))

Ben

On Thu, Jan 9, 2020 at 11:41 AM Bakary Faty  wrote:

>
> Dear,
>
> I'm writing to express my wish to join R-sig-geo list users.
> I was doing a search on the net to know how to build an isohyet map and I
> came across this R code.
> However, I stumbled upon a problem from the line :
> grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
> by=pixel)),
> I get the following error message:
> default method not implemented for type 'S4'. I want to know how resolve
> this error.
>
> Also, I would like to ask you only at the line level:
> minx <- rain_data_UTM at bbox[1,1]
> maxx <- rain_data_UTM at bbox[1,2]
> miny <- rain_data_UTM at bbox[2,1]
> maxy <- rain_data_UTM at bbox[2,2],
> if I should limit myself to "rain_data_UTM" or write completely:
> rain_data_UTM at bbox[,].
>  By the way, this is the pointfile I reconstructed.
> You can find it attached to the mail.
>
> Thanks in advance
>
> Best regards
>
>
>
> Bakary
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>


-- 
Ben Tupper
Bigelow Laboratory for Ocean Science
West Boothbay Harbor, Maine
http://www.bigelow.org/
https://eco.bigelow.org

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Help

2020-01-09 Thread Bakary Faty
Dear,

I'm writing to express my wish to join R-sig-geo list users.
I was doing a search on the net to know how to build an isohyet map and I
came across this R code.
However, I stumbled upon a problem from the line :
grd <- expand.grid(x=seq(minx, maxx, by=pixel), y=seq(miny, maxy,
by=pixel)),
I get the following error message:
default method not implemented for type 'S4'. I want to know how resolve
this error.

Also, I would like to ask you only at the line level:
minx <- rain_data_UTM at bbox[1,1]
maxx <- rain_data_UTM at bbox[1,2]
miny <- rain_data_UTM at bbox[2,1]
maxy <- rain_data_UTM at bbox[2,2],
if I should limit myself to "rain_data_UTM" or write completely:
rain_data_UTM at bbox[,].
 By the way, this is the pointfile I reconstructed.
You can find it attached to the mail.

Thanks in advance

Best regards



Bakary


pointfile.csv
Description: MS-Excel spreadsheet
___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Comparing distance among point pattern events

2020-01-09 Thread ASANTOS via R-sig-Geo
Dear R-Sig-Geo Members,

I have the three hypothetical point process situation (A, B and C) and my 
question is: What point distribution (B or C) is more close to A?

For this problem, I make a simple example:

library(spatstat)
set.seed(2023)
A <- rpoispp(30) ## First event
B <- rpoispp(30) ## Second event
C <- rThomas(10,0.02,5) ## Third event with Thomas cluster process
plot(A, pch=16)
plot(B, col="red", add=T)
plot(C, col="blue", add=T)

First, I takesthe distances between pairs of events:

ABd<-crossdist(A, B)
ACd<-crossdist(A, C)

mean(ABd)
# 0.4846027
mean(ACd)
# 0.5848766



# test the hypothesis that ABd is equal to ACd courtesy of Sarah Goslee

nperm <- 999

permout <- data.frame(ABd = rep(NA, nperm), ACd = rep(NA, nperm))

# create framework for a random assignment of B and C to the existing points

BC <- superimpose(B, C)
B.len <- npoints(B)
C.len <- npoints(C)
B.sampvect <- c(rep(TRUE, B.len), rep(FALSE, C.len))

set.seed(2023)
for(i in seq_len(nperm)) {
     B.sampvect <- sample(B.sampvect)
     B.perm <- BC[B.sampvect]
     C.perm <- BC[!B.sampvect]

     permout[i, ] <- c(mean(crossdist(A, B.perm)), mean(crossdist(A, C.perm)))
}


boxplot(permout$ABd - permout$ACd)
points(1, mean(ABd) - mean(ACd), col="red")

table(abs(mean(ABd) - mean(ACd)) >= abs(permout$ABd - permout$ACd))
#TRUE
# 999

sum(abs(mean(ABd) - mean(ACd)) >= abs(permout$ABd - permout$ACd)) / nperm
# [1] 1


The difference between ACd and ABd is distinguishable from that obtained by a 
random resampling of B and C.
Then B (0.4846027) is more close to A, that C (0.5848766).


But, now I comparing the distance to mean nearest neighbour and minimum 
distance between each pair of types:

marks(A)<-as.factor("A")
marks(B)<-as.factor("B")
marks(C)<-as.factor("C")

# distance to nearest neighbour A to B
nnda <- nncross(A,B, by=marks(A,B))

# mean nearest neighbour distances
mean(nnda[,1])
#[1] 0.09847543

# distance to nearest neighbour A to C
nndb <- nncross(A,C, by=marks(A,C))

# mean nearest neighbour distances
mean(nndb[,1])
#[1] 0.151127

# test again the hypothesis that ABd is equal to ACd

nperm <- 999

permout <- data.frame(ABd = rep(NA, nperm), ACd = rep(NA, nperm))

# create framework for a random assignment of B and C to the existing points

BC <- superimpose(B, C)
B.len <- npoints(B)
C.len <- npoints(C)
B.sampvect <- c(rep(TRUE, B.len), rep(FALSE, C.len))

set.seed(2023)
for(i in seq_len(nperm)) {
 B.sampvect <- sample(B.sampvect)
 B.perm <- BC[B.sampvect]
 C.perm <- BC[!B.sampvect]
 ab<-nncross(A, B.perm)
 ac<-nncross(A, C.perm)

 permout[i, ] <- c(mean(ab[,1]), mean(ac[,1]))
}


boxplot(permout$ABd - permout$ACd)
points(1, mean(nnda[,1]) - mean(nndb[,1]), col="red")

table(abs(mean(nnda[,1]) - mean(nndb[,1])) >= abs(permout$ABd - permout$ACd))
#FALSE  TRUE
#   91   908

sum(abs(mean(nnda[,1]) - mean(nndb[,1])) >= abs(permout$ABd - permout$ACd)) / 
nperm
#[1] 0.9089089


Now, the same conclusion or the mean nearest neighbour distances of A to B 
(0.10887343) is smaller than A to C (0.151127),
but is not so clear for me, what is the better approach if a comparing 
crossdist() and nndist () results for a good answer to my question?

Any conceptual tips?

Thanks in advance,

-- 
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 - Distrito Industrial
Caceres - MT - CEP 78.200-000 (ZIP code)
Phone: (+55) 65 99686-6970 / (+55) 65 3221-2674
Lattes CV: http://lattes.cnpq.br/1360403201088680
OrcID: orcid.org/-0001-8232-6722
ResearchGate: www.researchgate.net/profile/Alexandre_Santos10
Publons: https://publons.com/researcher/3085587/alexandre-dos-santos/
--

Em 22/11/2019 10:09, Sarah Goslee escreveu:
> Hi,
>
> Great question, and clear example.
>
> The first problem:
> ACd<-pairdist(A) instead of ACd <- pairdist(AC)
>
> BUT
>
> pairdist() is the wrong function: that calculates the mean distance
> between ALL points, A to A and C to C as well as A to C.
>
> You need crossdist() instead.
>
> The most flexible approach is to roll your own permutation test. That
> will work even if B and C are different sizes, etc. If you specify the
> problem more exactly, there are probably parametric tests, but I like
> permutation tests.
>
>
> library(spatstat)
> set.seed(2019)
> A <- rpoispp(100) ## First event
> B <- rpoispp(50) ## Second event
> C <- rpoispp(50) ## Third event
> plot(A, pch=16)
> plot(B, col="red", add=T)
> plot(C, col="blue", add=T)
>
> ABd<-crossdist(A, B)
> ACd<-crossdist(A, C)
>
> mean(ABd)
> # 0.5168865
> mean(ACd)
> # 0.5070118
>
>
> # test the hypothesis that ABd is equal to ACd
>
> nperm <- 999
>
> permout <- data.frame(ABd = rep(NA, nperm), ACd = rep(NA, nperm))
>
> # create framework for a random assignment of B and C to the existing points
>
> BC <- superimpose(B, C)
> B.len <- npoints(B)
> C.len <- npoints(C)
> B.sampvect <- c(rep(TRUE,