dankelley / oce

R package for oceanographic processing
http://dankelley.github.io/oce/
GNU General Public License v3.0
141 stars 42 forks source link

mapImage chokes on topoWorld #285

Closed richardsc closed 11 years ago

richardsc commented 11 years ago

I know mapImage is still pretty experimental, but maybe this can be motivation to get it fine tuned. I just tried using it to plot the topoWorld dataset, and it chokes in all instances. It seems to have something to do with wrapping past longitude 180, whether or not that meridian is in the plot. Some example code:

library(oce)
data(coastlineWorld)
data(topoWorld)
x11()  ## the plotting is *very* slow, especially on a quartz device
mapPlot(coastlineWorld)
mapImage(topoWorld)

A related issue is that it seems to have to draw the entire dataset, regardless of whether it's all in the range, which makes it very slow to plot.

Rplot001

dankelley commented 11 years ago

The source code you've given produces an error for me:

Error in dim(z) : 'z' is missing
richardsc commented 11 years ago

Ooops, try this:

library(oce)
data(coastlineWorld)
data(topoWorld)
lon <- topoWorld[['longitude']]
lat <- topoWorld[['latitude']]
z <- topoWorld[['z']]
x11()  ## the plotting is *very* slow, especially on a quartz device
mapPlot(coastlineWorld)
mapImage(lon, lat, z)
dankelley commented 11 years ago

I just pushed a develop commit that can take a topo object as first arg. Now looking at the actual bug.

dankelley commented 11 years ago

Pushed another commit that speeds up by 33%, but still has this bug.

dankelley commented 11 years ago

The horizontal-line problem is now fixed in the develop branch.

I'll now look at the problem of drawing the whole dataset. Normally, we rely on R for clipping to a box, but in this case we should be able to speed things up, because if all vertices in a polygon are outside par('usr') then we can skip it...

dankelley commented 11 years ago

Speeded up for sub-domains, as in test code:

library(oce)
data(coastlineWorld)
data(topoWorld)
x11()  ## the plotting is *very* slow, especially on a quartz device
mapPlot(coastlineWorld, latitudelim=c(45,50), longitudelim=c(-70,-50), projection='polyconic',orientation=c(90,-60,0))
mapImage(topoWorld)

@richardsc -- please close if this seems OK to you. Thanks!

dankelley commented 11 years ago

PS: it's still not terribly fast on sub-domains, but the problem is that mapproject() has to be called on every patch, before we can know whether to draw it.

richardsc commented 11 years ago

Thanks, looks good!

Yes, it is still kind of slow (more so when the sub-domain spans the prime meridian), but works as expected and looks pretty good.

Rplot001

Now, how about some other options consistent with imagep, including colormaps etc?! :)

dankelley commented 11 years ago

I wonder if you could put in an issue for color maps? That way, we have good granularity for changes. Thanks!