Hi everyone,I'm trying to run MaxEnt within the dismo package in R 2.15.2 running in Ubuntu Linux 12.10 (64-bit).The problem is that the maxent() function gives me an error saying "Error: No especies selected", after several warnings of extra fields in maxent temp files (please see below). When I check the temp files, there is actually a column named "species". I am working with just one species and the occurrence data are in a csv file containing only two columns (lon and lat), exactly as the program asks for. I am new using maxent and cannot figure out what is going on, so any help on this issue will be truly helpful.I am posting below the whole R code, so that you can inspect the code and the errors by yourselves.Thanks a lot,Luis--Luis O. LuciforaInstituto de Biología Subtropical - IguazúConsejo Nacional de Investigaciones Científicas y Técnicas (CONICET)Universidad Nacional de MisionesCentro de Investigaciones del Bosque Atlántico (CeIBA)Casilla de Correo 9Puerto Iguazú, Misiones, N3370AVQArgentinaR code:> library(maps)> library(rgdal)Loading required package: sprgdal: version: 0.8-4, (SVN revision 431)Geospatial Data Abstraction Library extensions to R successfully loadedLoaded GDAL runtime: GDAL 1.9.0, released 2011/12/29Path to GDAL shared files: /usr/share/gdal/1.9Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]Path to PROJ.4 shared files: (autodetected)> library(maptools)Loading required package: foreignLoading required package: gridLoading required package: latticeChecking rgeos availability: TRUE> library(dismo)Loading required package: rasterraster 2.0-41 (21-December-2012)> library(raster)>> #occurrence data>> ceto<-read.csv('/home/Work/projects/Cetorhinus/Cetorhinus_occur_dec_actualizado.csv', header=T,dec='.')> attach(ceto)>> #environment data> files <- list.files(path= '/home/Work/projects/Cetorhinus/', pattern='asc', full.names=TRUE)>> pred<-stack(files)>> #limit study area> e <- extent(-70, -40, -60, -10)> predictors<-crop(pred,e)> #plot(predictors)>> #separating train and test data> fold <- kfold(ceto, k=5)> occtest <- ceto[fold == 1, ]> occtrain <- ceto[fold != 1, ]>> #model> me <- maxent(predictors, occtrain)Loading required package: rJavaWarning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 2: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 3: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 4: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 5: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 6: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 7: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 8: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 9: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 10: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 11: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 12: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 13: skipping...Warning: Extra fields in /tmp/R_raster_tmp/root/maxent/6106210171031/presence line 14: skipping...Error: No species selectedError en file(con, "r") : no se puede abrir la conexiónAdemás: Mensajes de aviso perdidos1: In .local(x, p, ...) :2 (13.33%) of the presence points have NA predictor values2: In raster:::.couldBeLonLat(mask) :CRS is NA. Assuming it is longitude/latitude3: In file(con, "r") :no fue posible abrir el archivo '/tmp/R_raster_tmp/root/maxent/6106210171031/species.lambdas': No existe el archivo o el directorio>--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To post to this group, send email to max...@googlegroups.com.
Visit this group at http://groups.google.com/group/maxent?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
The error is referring to your occurrence data. I noticed that you've initially used "Dorcs" and then subsequently "Dorcas". You've also assigned your predictor stack to "preds" and then referred to it as "predictors" later. I imagine these are just typos in the code you've pasted here and aren't the cause of that particular error. However, the code you've given us looks fine otherwise...
Does the following example from ?maxent work for you?
fnames <- list.files(path=paste(system.file(package="dismo"), '/ex', sep=''), pattern='grd', full.names=TRUE )
predictors <- stack(fnames)
occurence <- paste(system.file(package="dismo"), '/ex/bradypus.csv', sep='')
occ <- read.table(occurence, header=TRUE, sep=',')[,-1]
# witholding a 20% sample for testing
fold <- kfold(occ, k=5)
occtest <- occ[fold == 1, ]
occtrain <- occ[fold != 1, ]
# fit model, biome is a categorical variable
me <- maxent(predictors, occtrain, factors='biome')
Visit this group at http://groups.google.com/group/maxent.
For more options, visit https://groups.google.com/d/optout.
Can you show me what you mean by "gathering XY"? You'll need to separate them into separate columns for x and y. I can show you how if you provide an example.
As the second error suggests, rJava requires that you have JDK installed. If you don't have it already, Google will tell you where to get it (here's one source: http://www.oracle.com/technetwork/java/javase/downloads/index.html?ssSourceSiteId=otnjp).
I can only view the file on my phone at the moment, and it seems there is no space or anything separating lon and lat. If these are all the records you have, just manually insert commas in each row, then use read.csv to bring it into R.
Otherwise, assuming your data.frame is called sp, and assuming that all latitudes have only 2 digits before the decimal point, you could do:
lon <- sub("(^\\d+\\.\\d+)\\d{2}\\..*", "\\1", so$LongLat)
lat <- sub("^\\d+\\.\\d+(\\d{2}\\..*)", "\\1", so$LongLat)
sp.new <- cbind(lon, lat)
I haven't tested this but I think syntax is correct.
Good luck!
Sorry, my phone auto-corrected sp to so in a couple of places..