Ugly horizontal line in map #2288
-
Hi, Dan. par(mar=c(4, 4, 1.5, 1.5))
data(coastlineWorld)
data(topoWorld)
ram_sites <- tbl_df(read.csv("~/PROJETOS/OTN_CNPq/ReNOMO/Questionario/ReNOMO-RAM_geral.csv", stringsAsFactors = FALSE, check.names = FALSE))
lonlim <- c(-67, -24)
latlim <- c(3,-34)
#topo <- decimate(topoWorld, 2) # coarsen grid: 4x faster
#topolat <- subset(topoWorld, latlim[1] < latitude & latitude < latlim[2])
topo <- subset(topoWorld, lonlim[1] < longitude & longitude < lonlim[2])
#faz o mapa
mapPlot(coastlineWorld, longitudelim = c(-50, -40), latitudelim = c(3,-34), projection="+proj=mill", col = 'lightgray', drawBox = TRUE, axes = TRUE)
breaks <- seq(-5000, 1000, 100)
mapImage(topo, col=oce.colorsGebco, breaks=breaks)
mapLines(coastlineWorld) # here is where the problem appears.
#plota pontos pretos grandes
mapPoints(ram_sites$Longitude, ram_sites$Latitude, col = "black", type = "p", pch=17, lwd=3)
mapText(ram_sites$Longitude, ram_sites$Latitude, ram_sites$Instituicao, pos=4) Any advice? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 6 replies
-
Hi Zeca, can you email me (dan dot kelley at dal dot ca) your code, and the data file(s) involved? It's easier when I can see things myself. My guess is that it is the "ugly lines" issue. Thanks! Dan. (PS. snowstorm here today. I'll send you a neat video of it, in reply to your email.) |
Beta Was this translation helpful? Give feedback.
-
I can confirm that it is the UHL (ugly horizontal lines). There are two ways that I know of to fix it:
I made a minimum working example from your code^1, and while method 1 seems to work, for reasons I don't understand method 2 doesn't ... |
Beta Was this translation helpful? Give feedback.
-
You're, fast, Clark! I suggest code like below. library(oce)
par(mar = c(4, 4, 1.5, 1.5))
data(coastlineWorld)
data(topoWorld)
lonlim <- c(-67, -24)
latlim <- c(3, -34)
topo <- subset(topoWorld, lonlim[1] < longitude & longitude < lonlim[2])
mapPlot(coastlineWorld,
longitudelim = c(-50, -40),
latitudelim = c(3, -34), projection = "+proj=mill", col = "lightgray", drawBox = TRUE, axes = TRUE
)
breaks <- seq(-5000, 1000, 100)
mapImage(topo, col = oce.colorsGebco, breaks = breaks)
mapLines(coastlineWorld)
# Zeca, try doing something like this, instead of the line above.
cl <- subset(coastlineWorld, -70 < longitude & longitude < -20 & -40 < latitude & latitude < 10)
mapLines(cl, col = 2, lwd = 3) # make wide red line to show clearly |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Also, Zeca, I noticed that there was no lat axis, so I added that. Also, I'm using polygons, like Clark suggested, so the land will be more obvious. Finally, note that I added some things to the projection specification. There are a LOT of choices for projection (there's a vignette on that, and its in my book too, plus many blog postings by Clark and me and others). library(oce)
par(mar = c(4, 4, 1.5, 1.5))
data(coastlineWorld)
data(topoWorld)
lonlim <- c(-67, -24)
latlim <- c(3, -34)
topo <- subset(topoWorld, lonlim[1] < longitude & longitude < lonlim[2])
mapPlot(coastlineWorld,
longitudelim = c(-50, -40),
latitudelim = c(3, -34), projection = "+proj=mill +lat0=-20 +lon0 = -45",
col = "lightgray", drawBox = TRUE, axes = TRUE
)
breaks <- seq(-5000, 1000, 100)
mapImage(topo, col = oce.colorsGebco, breaks = breaks)
cl <- subset(coastlineWorld, -70 < longitude & longitude < -20 & -40 < latitude & latitude < 10)
mapPolygon(cl, col = gray(0.9))
mapAxis(2)
mapGrid()
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Oh, you may now be addicted to looking at bathymetry !!!
If you think we have an answer, perhaps click one of the comments to indicate so, and close the discussion, so we can tell that things are settled now. If new things arise, please open up new discussions or issues. (PS I will open an issue tomorrow about the map axis but I'm doing something else today.)