[R] Problem with "different" proj4string that are actually identical

MacQueen, Don macqueen1 at llnl.gov
Fri Mar 20 16:23:44 CET 2015


This question would be better asked on r-sig-geo.

Here are some things to try (type at the R prompt):

  proj4string(spCro) == proj4string(paramdf)

Does it return TRUE or FALSE?

Or, instead of using summary(), directly inspect the proj4strings:

  proj4string(spCro)
  proj4string(paramdf)

If there still appears to be no difference between them,
try forcing them to be identical
  proj4string(spCro) <- proj4string(paramdf)

then repeat your niche.test()


-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/19/15, 5:29 PM, "Hemery, Lenaig" <Lenaig.Hemery at oregonstate.edu>
wrote:

>Dear everybody
>I am trying to run an Ecological Niche Factor Analysis (enfa) with the
>package "adehabitatHS" but before I do so, I want to test the
>significance of its parameters marginality and tolerance, by using the
>function niche.test() that runs a Monte Carlo test. I used to do that
>with the old package "adehabitat" that is now deprecated so I updated all
>my codes. Everything I want to do seems to work fine except the
>niche.test() function and I get the error message here below.
>
>> testCro<-niche.test(paramdf, spCro, nrep = 999, o.include = TRUE)
>Error in join(pts, ta) : different proj4string in x and xy
>
>I checked the proj4string for x (paramdf) and xy (spCro) and there are
>exactly identical (see below).
>
>> summary(spCro)
>Object of class SpatialPoints
>Coordinates:
>              min     max
>longitude -124.91 -124.13
>latitude    39.86   46.95
>Is projected: FALSE
>proj4string :
>[+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0]
>Number of points: 84
>
>> summary(paramdf)
>Object of class SpatialPixelsDataFrame
>Coordinates:
>         min       max
>x -125.50000 -123.7998
>y   39.50384   47.0000
>Is projected: FALSE
>proj4string :
>[+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0]
>Number of points: 108237
>Grid attributes:
>  cellcentre.offset cellsize cells.dim
>x        -125.49517  0.00966       176
>y          39.50867  0.00966       776
>Data attributes:
>      bath              slope              rugo               sumT
> Min.   :-3611.83   Min.   : 0.0000   Min.   :0.000000   Min.   : 1.184
> 1st Qu.:-1885.11   1st Qu.: 0.5271   1st Qu.:0.008044   1st Qu.: 2.150
> Median : -894.61   Median : 1.4974   Median :0.036921   Median : 3.978
> Mean   :-1157.85   Mean   : 3.4237   Mean   :0.147369   Mean   : 4.794
> 3rd Qu.: -150.85   3rd Qu.: 4.1152   3rd Qu.:0.197974   3rd Qu.: 7.388
> Max.   :   -0.05   Max.   :61.3592   Max.   :0.992856   Max.   :14.436
>[...]
>
>I think I looked for all the help I could find on the internet and didn't
>find any solution so here is my last chance.
>Does anybody have an idea on how to solve this problem?
>By the way, I use the R version 3.1.3 and up-to-date "adehabitatHS",
>"ade4", "sp" and other packages.
>Thanks a lot,
>Lenaig
>
>‰‰‰‰ ><)))°> <°(((>< ‰‰‰‰
>Lenaïg Hemery, Ph. D.
>Research Associate - post-doc
>Hatfield Marine Science Center
>Oregon State University
>2030 S.E. Marine Science Drive, Newport, OR 97365, USA
>Cell:+1-541-272-7196
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list