dankelley / oce

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

mapImage() with filledContour producing weird patterns #2199

Closed mdupilka closed 8 months ago

mdupilka commented 8 months ago

Starting about a months or so ago, using filledContour = TRUE in the mapImage() has been producing weird patterns. Here is an example

image

Here is the sample code to produce it

require(oce)
data("coastlineWorldMedium", package = "ocedata")
int <- .1
lon <- seq(-179.95, 179.95, int)
lat <- seq(-39.95, 89.95, int) 
m <- matrix(0, nrow = length(lon), ncol = length(lat))
mapPlot(coastlineWorldMedium,
        type = "polygon",
        col = "grey95",
        #projection="+proj=laea +lat0=40 +lat1=60 +lon_0=-110",
        projection = "+proj=lcc +lat_1=30 +lat_2=45 +lon_0=-110",
        #longitudelim = c(minlon, maxlon), latitudelim = c(minlat, maxlat),
        longitudelim = c(-140, -80), latitudelim = c(45, 70),
        polarCircle = 0,
        clip = TRUE, drawBox = TRUE,
        cex.axis = .7  )

mapImage(longitude = lon, latitude = lat, z = m,
         filledContour = TRUE,
         breaks = 10, 
         col = colorRampPalette(c("blue", "red"))(10) )

With filledContour = FALSE this does not happen

mdupilka commented 8 months ago

That worked. Interesting, if I set the fillgap > 0 and leave filledContour = TRUE I get a clean plot.

dankelley commented 8 months ago

Note that the right fillgap value is going to depend on the projection and the view being shown, etc.

PS. I am cleaning up some of the docs. This also involves changing what I was renaming gap in fillGapMatrix() to be fillgap. That's where the confusion came from -- I had decided on a given name for one thing and neglected to copy that same name for another thing that was really the same. I will rerun tests before I push to GH though.

mdupilka commented 8 months ago

I did more testing. Using fillgap=2 and filledContour = TRUE looks to fit my needs for a clean plot

dankelley commented 8 months ago

I made a blog posting comparing the methods. Sometimes I think this kind of thing is useful.

@mdupilka perhaps you can consider closing the issue after you feel it has been addressed. I think I'm done with my flurry of coding, unless there are new problems. In the oce community, we ask issue reporters to close issues. That just seems to be more respectful of reporters. (Related problems that do not quite match a given title should be in new issues, so please don't be shy on that.)

dankelley commented 8 months ago

Sorry, forgot to say that the blog post is at https://dankelley.github.io/dek_blog/2024/03/07/mapimage.html

dankelley commented 8 months ago

Thanks, @mdupilka and @richardsc, for your patience in this. I have merged the "2199" branch into the "develop" branch and then deleted "2199". So, if either of you is now on the "2199" branch, you'll need to hop over to "develop" before trying to "git pull" for any new results.