[R-sig-Geo] plotKML, GSIB on win xp_examples

Tomislav Hengl hengl at spatial-analyst.net
Tue Oct 23 10:45:31 CEST 2012


Axel,

The problem with the predict method was that dismo package did not 
export it properly before. Robert and I have solved this problem a month 
ago (dismo_0.7-23), but you do need to use GSIF package version 0.2-3 
(2012-10-18) to overcome this bug.

Please send me what you get for:

 > packageDescription("GSIF")
Package: GSIF
Type: Package
Title: Global Soil Information Facilities
Version: 0.2-3
Date: 2012-10-18

 > showMethods("predict")
Function: predict (package stats)
object="ANY"
object="Bioclim"
object="CirclesRange"
object="ConvexHull"
object="Domain"
object="GeographicDistance"
object="gstatModel"
object="InvDistWeightModel"
object="list"
object="Mahalanobis"
object="MaxEnt"
object="MaxEntReplicates"
object="Raster"
object="VoronoiHull"


On 22/10/2012 22:13, Axel Hille wrote:
> Dear Tom,
> thanks for your hints. I usually install new packages for R from source
> under my wIN xp: i ALSO DID WITH BOTH THE LATEST PACKAGES OF PLOTkml AND
> gsib: After new install in both examples the error messages remain the
> same, for example
>  > if(file.exists(jar)){
> +    me.eberg <- MaxEnt(occurrences=eberg.ppp, covariates=eberg_grid)
> +    par(mfrow=c(1,2), mar=c(0.5,0.5,0.5,0.5), oma=c(0,0 .... [TRUNCATED]
> Fehler in UseMethod("predict") :
>    nicht anwendbare Methode für 'predict' auf Objekt der Klasse
> "c('MaxEnt', 'DistModel')" angewendet
> Zusätzlich: Warnmeldung:
> In .local(x, p, ...) :
>    1 (0.12%) of the presence points have NA predictor values
> In both cases it complains first, no method available for "predict" of
> class "c('MaxEnt', 'DistModel')"  and additional a warning (0.12%) of
> the presence points have NA predictor values. So i will try it under
> Ubuntu 10.04, maybe there are some peculiar windows problems with
> installation (please see attached).
> Best wishes
> Axel
>>
>> -------- Original-Nachricht --------
>> Datum: Mon, 22 Oct 2012 15:58:13 +0200
>> Von: Tomislav Hengl <hengl at spatial-analyst.net>
>> An: Axel Hille <axel.hille at gmx.net>
>> Betreff: Re: plotKML, GSIB on win xp_examples
>>
>>
>>
>> On 18/10/2012 22:37, Axel Hille wrote:
>> > Dear Tom,
>> > once again, it was a great workshop in Muenster! Learned a lot.
>> > I came back to my project. Want to do species distribution modelling. I
>> > made already a successful trial with SDM and the raster package and
>> > exported the data to GE. But your packages seems much more convenient to
>> > produce KML files. So I first tried your samples on MaxEnt. I installed
>> > the latest plotKML (0.2-5) and GSIB.
>> > But in both examples got the same error message, some percentage of NA
>> > values (see below). Is Should I exlude the NA values. Or should the area
>> > be defined also? Just wanted to know if you yourself tested those models
>> > or maybe it is also a problem concerning my installation?
>> > I used R-2.15.1 on Win XP.
>> > I hope to hear from you.
>> > Many thanks and best wishes
>> > Axel
>> >
>>
>> Sorry for some delay... been traveling around :)
>>
>> >
>> >
>> > setwd("~")
>> > getwd()
>> > library(plotKML)
>> > ?plotKML
>> > ## -------------- SpatialMaxEntOutput --------- ##
>> > data(bigfoot)
>> > aea.prj <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96
>> > +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
>> > coordinates(bigfoot) <- ~Lon+Lat
>> > proj4string(bigfoot) <- CRS("+proj=latlon +datum=WGS84")
>> > str(bigfoot)
>> > bigfoot.aea <- spTransform(bigfoot, CRS(aea.prj))
>> > str(bigfoot.aea)
>> > library(spatstat)
>> > #?spatstat::as.ppp
>> > #xy <- matrix(runif(40), ncol=2)
>> > #pp <- as.ppp(xy, c(0,1,0,1))
>> > #pp
>> > plot(bigfoot)
>> > bigfoot.aea <- as.ppp(bigfoot.aea)
>> > str(bigfoot.aea)
>> > # Load the covariates:
>> > data(USAWgrids)
>> > gridded(USAWgrids) <- ~s1+s2
>> > proj4string(USAWgrids) <- CRS(aea.prj)
>> > sel.grids <- c("globedem","nlights03","sdroads","gcarb","twi","globcov")
>> > str(sel.grids)
>> > str(USAWgrids[sel.grids])
>> > # run MaxEnt analysis (evaluates sampling bias or mis-representation):
>> > library(dismo)
>> > library(rJava)
>> > jar <- paste(system.file(package="dismo"), "/java/maxent.jar", sep='')
>> > library(GSIF)
>> > #?GSIF::MaxEnt
>> > bigfoot.smo <- MaxEnt(bigfoot.aea, USAWgrids[sel.grids])
>> > #Fehler in UseMethod("predict") :
>> > # nicht anwendbare Methode für 'predict' auf Objekt der Klasse
>> > "c('MaxEnt', 'DistModel')" angewendet
>> > #zusätzlich: Warnmeldung:
>> > #In .local(x, p, ...) :
>> > # 55 (7.21%) of the presence points have NA predictor values
>> > #
>>
>> You need to install the most recent version of GSIF:
>>
>> > download.file("http://gsif.r-forge.r-project.org/GSIF_0.2-3.tar.gz",
>> "GSIF_0.2-3.tar.gz")
>> > system("R CMD INSTALL GSIF_0.2-3.tar.gz")
>>
>> you should then get:
>>
>> > library(GSIF)
>> ...
>> GSIF version 0.2-3 (2012-10-18)
>> URL: http://gsif.r-forge.r-project.org/
>>
>> The code to test if the MaxEnt function works is at:
>>
>> http://gsif.r-forge.r-project.org/MaxEnt-method.html
>>
>> I'm very sorry you have to install GSIF from source code. There seems to
>> be that there is some problem with the R-forge package survival
>> [http://r-forge.r-project.org/R/?group_id=1125&log=build_win64&pkg=GSIF&flavor=patched],
>>
>> which is beyond me.
>>
>> all the best with your work!
>>
>> > icon = "http://plotkml.r-forge.r-project.org/bigfoot.png"
>> > plotKML(bigfoot.smo, colour_scale = R_pal[["bpy_colors"]], shape =
>> > icon)
>> >
>> >
>> >
>> > ## Not run: # load data:
>> > library(plotKML)
>> > data(eberg)
>> > data(eberg_grid)
>> > # prepare data for spatial analysis:
>> > eberg.xy <- eberg[runif(nrow(eberg)) < .3,]
>> > str(eberg.xy)
>> > coordinates(eberg.xy) <- ~X+Y
>> > proj4string(eberg.xy) <- CRS("+init=epsg:31467")
>> > # format gridded data:
>> > gridded(eberg_grid) <- ~x+y
>> > proj4string(eberg_grid) <- CRS("+init=epsg:31467")
>> > # convert to a "ppp" object:
>> > library(spatstat)
>> > eberg.ppp <- as.ppp(eberg.xy)
>> > eberg.ppp
>> > library(dismo)
>> > # run MaxEnt analysis (evaluates sampling bias or mis-representation):
>> > jar <- paste(system.file(package="dismo"), "/java/maxent.jar", sep='')
>> > if(file.exists(jar)){
>> > me.eberg <- MaxEnt(occurrences=eberg.ppp, covariates=eberg_grid)
>> > ## NOTE: MaxEnt can be time-consuming!
>> > # plot the results:
>> > par(mfrow=c(1,2), mar=c(0.5,0.5,0.5,0.5), oma=c(0,0,0,0))
>> > image(as(me.eberg at predicted, "SpatialPixelsDataFrame"),
>> > col=rev(heat.colors(25)), xlab="", ylab="")
>> > points(me.eberg at occurrences, pch="+", cex=.7)
>> > image(me.eberg at sp.domain, col="grey", xlab="", ylab="")
>> > }
>> > #Fehler in UseMethod("predict") :
>> > # nicht anwendbare Methode für 'predict' auf Objekt der Klasse
>> > "c('MaxEnt', 'DistModel')" angewendet
>> > #Zusätzlich: Warnmeldungen:
>> > #1: some mark values are NA in the point pattern x
>> > #2: In .local(x, p, ...) :
>> > # 1 (0.13%) of the presence points have NA predictor values
>> >
>> >
>> >> -------- Original-Nachricht --------
>> >> Datum: Tue, 28 Aug 2012 10:41:26 +0200
>> >> Von: Tomislav Hengl <hengl at spatial-analyst.net>
>> >> An: Axel Hille <axel.hille at gmx.net>
>> >> Betreff: Re: plotKML, GSIB on win xp
>> >>
>> >>
>> >> Axel,
>> >>
>> >> First thing you have to use the R 2.15.1, because the package has been
>> >> compiled on that version of R.
>> >>
>> >> Second, try downloading the most recent version of the GSIF package:
>> >>
>> >> http://gsif.r-forge.r-project.org/
>> >>
>> >> When you install GSIF successfully, then check that you have the most
>> >> recent version:
>> >>
>> >> > packageDescription("GSIF")
>> >> Package: GSIF
>> >> Type: Package
>> >> Title: Global Soil Information Facilities
>> >> Version: 0.2-2
>> >> Date: 2012-08-24
>> >> Author: Tomislav Hengl <tom.hengl at wur.nl>, Contributions by:
>> >> Bas Kempen <bas.kempen at wur.nl>, Dylan Beaudette
>> >> <debeaudette at ucdavis.edu>, Gerard B.M. Heuvelink
>> >> <gerard.heuvelink at wur.nl>, Reuter I. Hannes
>> >> <hannes.reuter at wur.nl>, Brendan Malone
>> >> <brendan.malone at sydney.edu.au>, Pierre Roudier
>> >> <roudierp at landcareresearch.co.nz>
>> >> Maintainer: Tomislav Hengl <tom.hengl at wur.nl>
>> >> Description: Global Soil Information Facilities - tools
>> >> (standards and functions) and sample datasets for
>> >> global soil mapping.
>> >> License: GPL
>> >> URL: http://gsif.r-forge.r-project.org/
>> >> LazyLoad: yes
>> >> Depends: R (>= 2.12.0), methods, stringr, XML, RCurl, sp,
>> >> maptools, rgdal, raster, plotKML, aqp, dismo
>> >> Suggests: soiltexture, RSAGA, splines, gstat, boot, mda,
>> >> psych, fossil, nnet, SDMTools, rJava (>= 0.5-0)
>> >> Repository: R-Forge
>> >> Repository/R-Forge/Project: gsif
>> >> Repository/R-Forge/Revision: 51
>> >> Packaged: 2012-08-24 18:19:34 UTC; rforge
>> >> Built: R 2.15.1; ; 2012-08-24 17:45:28 UTC; windows
>> >>
>> >>
>> >> There were some issues with the 32-bit and 64-bit OS that I am still
>> >> trying to resolve.
>> >>
>> >> Officially, you should be able to install GSIF from R-forge and plotKML
>> >> from CRAN:
>> >>
>> >> > install.packages("plotKML")
>> >> > install.packages("GSIF", repos="http://R-Forge.R-project.org")
>> >>
>> >> see you next week,
>> >>
>> >> T. Hengl
>> >>
>> >>
>> >>
>> >> On 27/08/2012 21:28, Axel Hille wrote:
>> >> > Dear Tom,
>> >> > I tried to check-install plotKML and depending GSIB under Windows
>> XP and
>> >> > R.2.15.0.
>> >> > I checked the sources (plotKML_0.2-4.tar.gz, GSIF_0.2-2.tar.gz, ) and
>> >> > sucessfully installed plotKML (and almost started the examples).
>> But the
>> >> > check of GSIB failed, some class dependencies etc. I attach the log
>> >> > files (in German, I hope you can understand it).
>> >> > Can I also plot automap SpatialGrids with plotKML instead of GSIB
>> >> output?
>> >> > See you in Munster, best wishes
>> >> > Axel Hille
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Dr. rer. nat. Axel Hille
>> >> > Diplom-Biologe
>> >> >
>> >
>> >
>> >
>> > --
>> > Dr. rer. nat. Axel Hille
>> > Diplom-Biologe
>> >
>
>
>
> --
> Dr. rer. nat. Axel Hille
> Diplom-Biologe
>



More information about the R-sig-Geo mailing list