tmap icon indicating copy to clipboard operation
tmap copied to clipboard

`tm_lines` results in graphical artifacts

Open James-G-Hill opened this issue 1 year ago • 3 comments

I create a simple map with a states layer and then a series of lines representing the Eastern coast of the US. I applied a palette to the lines along with a categorical variable. Unfortunately the lines appear to have artifacts, presumably where they maybe overlapping at the ends due to the line width option.

I wondered if this would be temporarily fixable if there was an option that could allow selection of the butt or square line end type?

Screenshot 2024-02-12 014946

James-G-Hill avatar Feb 12 '24 01:02 James-G-Hill

In v4, you can change the lineend and line join. These are arguments of tm_lines, passed on to gpar (see details there). E.g.

tm_shape(rivers)+
	tm_lines(col = "scalerank", lwd = 5, lineend = "butt")

mtennekes avatar Feb 12 '24 21:02 mtennekes

Thanks @mtennekes I will try this to see if there is an improvement.

James-G-Hill avatar Feb 14 '24 10:02 James-G-Hill

I realised what was causing this problem; I guess it maybe not a bug at all. The lines I had were actually a collection of simple features multi-lines. When I simplified these with sf::_st_simplify the problem mostly disappeared. It appears that the ends of the lines sometimes are little pixely but this was made far worse by the use of many smaller lines with the multi-line type.

James-G-Hill avatar Apr 12 '24 20:04 James-G-Hill