From: Peter Ehlers <ehlers_at_ucalgary.ca>

Date: Fri, 01 Apr 2011 15:48:00 -0700

}

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 01 Apr 2011 - 22:51:12 GMT

Date: Fri, 01 Apr 2011 15:48:00 -0700

Steve,

I was just about to send off another suggestion which began with ...

Try the following or wait for David W. to chime in.

But I see that he's already done that. Anyway, in case it's still of some use:

First I would check that you don't have a variable 'T' in your workspace. (Never use T in place of TRUE.)

Then I would check that x and y are as they should be.

Then I would make sure that temp is of the correct type (a matrix) by letting j take a few values (1,2,varsize[4]-1), generating temp, and running str(temp). I assume that varsize[4] is >= 2.

Then I would run the following stripped-down version of your loop (note that I modified your contour() call):

for(j in 1:2) {

temp <- get.var.ncdf(nc=input, varid="p_foraging",c(1,1,j),c(varsize[1],varsize[2],1) ) filled.contour(x, y, temp, plot.axes = { contour(x, y, temp, add = TRUE) axis(1, seq(450000 , 580000, by = 10000)) axis(2, seq(2800000,4000000, by = 10000)) }

}

If that gives reasonable results, you can add the prettyfying statements back in. If you still get errors, then either I'm out-to-lunch (quite possible!) or you need to use debug() to figure out what's going on.

Peter Ehlers

On 2011-04-01 14:59, David Winsemius wrote:

*>
*

> On Apr 1, 2011, at 5:38 PM, Steve_Friedman@nps.gov wrote:

*>
**>> Hi Peter,
**>>
**>> Thanks for taking the time to consider the problem. I realize the
**>> procedure
**>> is not reproducible. I use a 4 dimensional netCDF file (4.2 GB) in
**>> size to
**>> pull data into this process. Nobody in their right mind should work
**>> with
**>> such things. It's a spatial temporal database with 10 years of daily
**>> data
**>> in a irregular area spanning 405 x 287 cells.
**>>
**>> Anyway, I tried your suggestion adding a { in front of the for loop
**>> and a
**>> closing } following the last line.
**>
**> That suggestion was probably intended to get you a more informative
**> error message:
**>
**> for(j in 1:(varsize[4]-1) )
**> temp<- get.var.ncdf(
**> nc=input,
**> varid="p_foraging",
**> c(1,1,j),
**> c(varsize[1], varsize[2], 1)
**> )
**>
**> # I think Peter is correct. That loop will complete before the call to
**> filled.contour,
**> # so you will only have the last version of temp plot.
**>
**> filled.contour(x, y, temp, color = terrain.colors,
**> plot.title = title( main =
**> paste("Everglades Wood Stork Foraging Potential \nYear",
**> (2000+j)),
**>
**> #that "double call" to title looks incomplete as well. The comma looks
**> premature.
**> # Shouldn't it be something like:
**> plot.title = bquote("Everglades Wood Stork Foraging Potential
**> \nYear", .(2000+j) )
**>
**> #(And since the for loop is already complete `j` will not exist.
**> # Which is probably the source of the error you are getting.)
**>
**> xlab = "UTM East", ylab = "UTM North") ,
**> plot.axes = { contour(temp, add=T)
**> axis(1, seq(450000 , 580000, by = 10000))
**> axis(2, seq(2800000,4000000, by = 10000)) },
**> key.title = title(main="Probability") ,
**> key.axes = axis(4, seq(0 , 1 , by = 0.1))
**>>
**>> It did not work.
**>>
**>>
**>> Steve Friedman Ph. D.
**>> Ecologist / Spatial Statistical Analyst
**>> Everglades and Dry Tortugas National Park
**>> 950 N Krome Ave (3rd Floor)
**>> Homestead, Florida 33034
**>>
**>> Steve_Friedman_at_nps.gov
**>> Office (305) 224 - 4282
**>> Fax (305) 224 - 4147
**>>
**>>
**>>
**>> Peter Ehlers
**>> <ehlers_at_ucalgary.
**>>
**>> ca> To
**>> "Steve_Friedman_at_nps.gov"
**>> 04/01/2011 05:08<Steve_Friedman_at_nps.gov>
**>>
**>> PM cc
**>> "r-help_at_r-project.org"
**>> <r-help_at_r-project.org>
**>>
**>> Subject
**>> Re: [R] filled contour plot with
**>> contour lines
**>>
**>>
**>>
**>>
**>>
**>>
**>>
**>>
**>>
**>>
**>> Aren't you missing a set of parentheses?
**>> I can't run your code since it's not reproducible, but to
**>> my aging eyes it seems that you need a set of '{}' around
**>> the contents of your loop:
**>>
**>> for(j in 1:(varsize[4]-1)) { loop stuff }
**>>
**>> Peter Ehlers
**>>
**>> On 2011-04-01 11:48, Steve_Friedman_at_nps.gov wrote:
**>>>
**>>> I'm stumped, can anyone find my error in this sequence.
**>>>
**>>> for(j in 1:(varsize[4]-1))
**>>> temp<- get.var.ncdf(nc=input,
**>>> varid="p_foraging",c(1,1,j),c(varsize[1],varsize[2],1))
**>>> filled.contour(x, y, temp, color = terrain.colors,
**>>> plot.title = title(main = paste("Everglades Wood Stork
**>>> Foraging Potential \nYear", (2000+j)),
**>>> xlab = "UTM East", ylab = "UTM North") ,
**>>> plot.axes = { contour(temp, add=T)
**>>> axis(1, seq(450000 , 580000, by = 10000))
**>>> axis(2, seq(2800000,4000000, by = 10000)) },
**>>> key.title = title(main="Probability") ,
**>>> key.axes = axis(4, seq(0 , 1 , by = 0.1))
**>>>
**>>>
**>>> The routine will work in a modified form without adding the
**>>> coordinates
**>>> (the axis lines) but when I include these the routine produces
**>>> various
**>>> errors, such as "dimension mismatch", or "unexpected end
**>>> encountered."
**>>>
**>>> I tried to follow the example on filled.contour help page.
**>>>
**>>> Thanks in advance
**>>> Steve
**>>>
**>>> Steve Friedman Ph. D.
**>>> Ecologist / Spatial Statistical Analyst
**>>> Everglades and Dry Tortugas National Park
**>>> 950 N Krome Ave (3rd Floor)
**>>> Homestead, Florida 33034
**>>>
**>>> Steve_Friedman_at_nps.gov
**>>> Office (305) 224 - 4282
**>>> Fax (305) 224 - 4147
**>>>
**>>> ______________________________________________
**>>> R-help_at_r-project.org mailing list
**>>> https://stat.ethz.ch/mailman/listinfo/r-help
**>>> PLEASE do read the posting guide
**>> http://www.R-project.org/posting-guide.html
**>>> and provide commented, minimal, self-contained, reproducible code.
**>>
**>> ______________________________________________
**>> R-help_at_r-project.org mailing list
**>> https://stat.ethz.ch/mailman/listinfo/r-help
**>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
**>> and provide commented, minimal, self-contained, reproducible code.
**>
**> David Winsemius, MD
**> West Hartford, CT
**>
**> ______________________________________________
**> R-help_at_r-project.org mailing list
**> https://stat.ethz.ch/mailman/listinfo/r-help
**> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
**> and provide commented, minimal, self-contained, reproducible code.
*

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 01 Apr 2011 - 22:51:12 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sat 02 Apr 2011 - 00:20:26 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*