1

I can not get this for loop to run in GME because i is being changed to 1 and , out is not recognized: wd <- "C:\Users\name\Desktop\KDE\2011\"; for (i in 1:15) { kde(in="C:\Users\name\Desktop\KDE\first15clip.shp"), out=paste(wd, "kde_p", 1, ".img"), bandwidth=1000, cellsize=10, where=paste("PName_ID=", 1)); }

Warning: An unexpected command argument was encountered: , out. The tool will attempt to run anyway, but may not produce the output you intended it to. Please check the results carefully. WHERE clause: PName_ID=1 Error: The command text could not be interpreted. Please check the syntax of the command. Error: An important error has occurred. Please include the information below if you submit a query about this error. Length cannot be less than zero. Parameter name: length

  • Does anyone have any ideas to fix this? – EJrandom Jan 10 '15 at 16:37
2

In case anyone is still confused about this and needs an answer...Refer to page 12 of SpatialEcologyGME http://www.spatialecology.com/gme/images/SpatialEcologyGME.pdf.

Your i was changed to a 1 because the Output tab in GME displays the literal statements you tell it to execute. So each iteration of your for loop executes a kde statement with whatever i evaluates to instead of "i."

The main problem I see in this code is that sep='' is not specified in your calls to paste().

Try,

    out=paste(wd, "kde_p", i, ".img", sep='')

and

    where=paste(""PName_ID"=", i)

for those KDE input parameters. Use those extra quotes if you're typing these commands directly into the Command Text tab in GME.

I highly recommend building your commands in R using cat() and paste() and writing to some text file, which you can then run in GME (File -> Run GME Script).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.