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\KDE2011円\"; 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

Any ideas on how to fix this so the loop runs?

asked Jan 9, 2015 at 19:04

1 Answer 1

1

You are using R syntax, why not just do this in R? Anyway, I have no idea how GME is parsing to R but from an syntax standpoint your backslashes either need to be double ("\") or single forward slashes ("/").

I believe that your actual issue is that you need a separator argument in the paste function. The way you have it now is creating a space between the two strings.

inpath <- "C:/Users/name/Desktop/KDE/"
 paste(inpath, "first15clip.shp")

Which results in: "C:/Users/name/Desktop/KDE/ first15clip.shp"

As opposed to:

paste(inpath, "first15clip.shp", sep="")

Which results in: "C:/Users/name/Desktop/KDE/first15clip.shp"

Your "out" argument will cause you issues as well. If you run it as it is, with i=1, it would look like this: "C:/Users/name/Desktop/KDE/2011/ kde_p 1 .img"

This syntax:

outpath <- "C:/Users/name/Desktop/KDE/2011/" 
 paste(outpath, paste("kde_p", i, ".img", sep=""), sep="")

results in : "C:/Users/name/Desktop/KDE/2011/kde_p1.img"

answered Jan 9, 2015 at 19:44
5
  • This is GME's example for writing a for loop in GME: Commented Jan 9, 2015 at 19:53
  • inpath <- "C:\data\" outpath <- "C:\output\" for (i in 1001:1010) { for (j in 1:12) { kde(in=paste(inpath, "telemetry.shp"), out=paste(outpath, "kde an", i, " m", j, ".img"), bandwidth=1000, cellsize=r.eval((250000-120000)/2000), where=paste("ANIMALID=", i, " AND MONTH=", j)); }; }; Commented Jan 9, 2015 at 19:55
  • when I try it with my Pname_ID replacing ANIMALID: Commented Jan 9, 2015 at 19:56
  • inpath <- "C:\Users\ejraynor\Desktop\KDE\"outpath <- "C:\Users\ejraynor\Desktop\KDE2011円\"for (i in 1:15); kde(in=paste(inpath, "first15clip.shp", sep=""), out=paste(outpath, "kde_p_", i, ".img"), bandwidth=1000, cellsize=10, where=paste("PName_ID=", i)); Error: The default input/output working folders have not been specified, therefore not enough information has been supplied to open the specified data source Error: Could not open input point data source. Commented Jan 9, 2015 at 19:56
  • 1
    In looking at the ked and for help, your syntax is correct. Have you tried the kde syntax outside of the for loop? Perhaps contact the developer Hawth Beyer. You should be aware that GME is mostly just calling R. The for loop syntax you have is the exactly the same as what you would specify in R and, since R packages are moving at a much faster pace than GME, which is not leveraging improvements in R spatial classes, it seems prudent to just learn and use R. For a density analysis a good place to start would be the ppp.density function in spatstat. Commented Jan 9, 2015 at 21:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.