[R-sig-Geo] Re : Ecological Niche Factor Analysis

alannie agg18 at pitt.edu
Fri May 30 21:47:11 CEST 2014


Thanks Mathieu!

This has gone very well so far, but I cannot seem to get the XY location
data and the bioclim maps in the same proj4string.
 CODE: pr <- slot(count.points(corysp, bio), "data")[,1]
Error in count.points(corysp, bio) : different proj4string in w and xy

This seems strange since everything in the same coordinate system WGS 1984
from previous analysis.

 class(corysp)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"

summary(corysp)
Object of class SpatialPointsDataFrame
Coordinates:
                min       max
coords.x1 -124.1643 -119.7514
coords.x2   37.0000   40.8030
Is projected: NA
proj4string : [NA]
Number of points: 44
Data attributes:
               taxon_name   Y_latitude      X_longitud
 Collinsia corymbosa:44   Min.   :37.00   Min.   :-124.2
                          1st Qu.:37.98   1st Qu.:-123.8
                          Median :39.46   Median :-123.8
                          Mean   :38.99   Mean   :-123.3
                          3rd Qu.:39.50   3rd Qu.:-122.6
                          Max.   :40.80   Max.   :-119.8


I have tried to change the coordinate system using
CODE:

coordsp<-SpatialPoints(corysp, proj4string=CRS(as.character(NA)), bbox =
NULL)

But get the same issue:

pr <- slot(count.points(coordsp, bio), "data")[,1]
Error in count.points(coordsp, bio) : different proj4string in w and xy


Also, I still cannot may histograms using the bioclim map data.


Thanks so much for your assistance! You have helped me so much!


Alannie




>
>
> Dear Alannie,
>
> I think your problem comes from the handling of rasters as sp classes, not
> from the actual ENFA methods. You should try to import the rasters
> properly first, and check that they are actually valid
> 'SpatialPixelsDataFrame's. For instance, using rgdal:
>
> library(rgdal)
> bio1 <- readGDAL("bio1.asc")
> bio2 <- readGDAL("bio2.asc")
> bio3 <- readGDAL("bio3.asc")
> bio <- cbind(bio1, bio2, bio3)
> names(bio) <- c("bio1", "bio2", "bio3")
> summary(bio)
> image(bio)
> spplot(bio)
> ...
>
> The rest of the analysis should work as expected.
> Mathieu.
>
>
> --
>
> ~$ whoami
> Mathieu Basille, PhD
>
> ~$ locate --details
> University of Florida \\
> Fort Lauderdale Research and Education Center
> (+1) 954-577-6314
> http://ase-research.org/basille
>
> ~$ fortune
> « Le tout est de tout dire, et je manque de mots
> Et je manque de temps, et je manque d'audace. »
>   -- Paul Éluard
> ---- Le mar., 27 mai 2014 21:56:19 -0400 alannie  a écrit ----
>
>>Hi,
>>
>>I have been using ENFA in R to perform some analyses.
>>
>>I have gotten the procedure to work before, however I can't seem to
>>replicate the code. This is very important since I would like to do this
>>analysis for a wide range of species.
>>
>>Please advise of best practice for implementing the procedure.
>>
>>Going from the very beginnings of the procedure:
>>
>>1) read in .csv formatted locations data for the interested species
>>
>> /code/ species1<-read.csv("species1.csv",head=T, sep=",")
>> species1coords<-SpatialPoints(species1)
>>
>>2) read in raster files (I am using the bioclim variables converted into
>>ASCII)
>>
>> /code/ b1<-read.asc("bio1.asc")
>> b2<-read.asc("bio2.asc")
>> b3<-read.asc("bio3.asc")
>>
>>3) combine the maps into a single data frame and add slots to the
>> individual
>>maps
>> /code/ map<-cbind(b1 at data,b2 at data,b3 at data) *this form does not allow me
>>to visualize the maps using image(map)
>> map2<-cbind(b1,b2,b3) *this form, with out the slots,
>>does allow me to visualize the maps using image(map2)
>>
>>4) following this step is making a histogram: hist(map, type = "l") I
>>usually cannot make one, but when I am able to make a histogram, the
>>variables show up on a single graph with the warning:
>>
>>Warning messages:
>>1: In title(main = main, sub = sub, xlab = xlab, ylab = ylab, ...) :
>> graphical parameter "type" is obsolete
>>2: In axis(1, ...) : graphical parameter "type" is obsolete
>>3: In axis(2, ...) : graphical parameter "type" is obsolete
>>
>>4) The tab:
>> /code/ tab <- slot(map, "data"), I get this warning:
>>Error in slot(map, "data") :
>> cannot get a slot ("data") from an object of type "double"
>>
>>Sometimes I get other warnings such as 'x is not numeric' or something
>> about
>>NA values.
>>
>>I will spare the rest of the issues I face.
>>
>>I believe the origins of these issues are the starting data inputs. I
>> would
>>appreciate any assistance in modifying the data inputs. I have tried to
>> look
>>through other resources, however I have not found anything to help with
>> my
>>specific issues.
>>
>>If I can get this worked out, I also hope to post some code somewhere to
>>aide others in their SDM adventures.
>>
>>Thank you for reading!
>>
>>A
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>--
>>View this message in context:
>> http://r-sig-geo.2731867.n2.nabble.com/Ecological-Niche-Factor-Analysis-tp7586516.html
>>Sent from the R-sig-geo mailing list archive at Nabble.com.
>>
>>_______________________________________________
>>R-sig-Geo mailing list
>>R-sig-Geo at r-project.org
>>https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
>
> ~$ whoami
> Mathieu Basille, PhD
>
> ~$ locate --details
> University of Florida \\
> Fort Lauderdale Research and Education Center
> (+1) 954-577-6314
> http://ase-research.org/basille
>
> ~$ fortune
> « Le tout est de tout dire, et je manque de mots
> Et je manque de temps, et je manque d'audace. »
>  -- Paul Éluard
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://r-sig-geo.2731867.n2.nabble.com/Ecological-Niche-Factor-Analysis-tp7586516p7586523.html
> To start a new topic under R-sig-geo, email
> ml-node+s2731867n2731867h11 at n2.nabble.com
> To unsubscribe from Ecological Niche Factor Analysis, visit
> http://r-sig-geo.2731867.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7586516&code=YWdnMThAcGl0dC5lZHV8NzU4NjUxNnwtMjAxOTYzNDk0MQ==







--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Re-ReA-Ecological-Niche-Factor-Analysis-tp7586535.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list