Description
Triggered by #457
Historically in tmap, projected spatial objects were preferred, not just for plotting, but also for calculating distances and areas. (With the important message to use a proper CRS for the map area). Nowadays, calculation of distances and areas is easy with s2. Not sure about the accuracy, but at least good enough and at least better than an unsuitable CRS, and therefore safer to use.
We need to decide where to do the CRS transformation in the process: before step 3 (transformation, e.g. cartograms, centroids, etc), or before step 4 (plotting). In the current v4 implementation, it takes place before step 3, but if the crs is specified as option, it is subsequently applied in step 4 (needed for the view mode). If the keep this approach, then we need to think about how to specify the crs and bbox for step 4 only.
# this is good: crs used for geometric distortion in step 3, and also for step 4 (plotting)
tm_shape(World, crs = "+proj=robin") +
tm_cartogram(size = "pop_est")
# this is not so good, because there may be step-3 layer transformations,
# for which an orthogonal projection is not good for global use cases
tm_shape(World, crs = "+proj=ortho +lat_0=0 +lon_0=0") +
tm_polygons() +
tm_style("natural")
# better to use this crs only in step 4:
tm_shape(World) +
tm_polygons() +
tm_style("natural") +
tm_options( crs = "+proj=ortho +lat_0=0 +lon_0=0")
But this is not very user-friendly I guess. Should be add another element for this purpose @Nowosad @nickbearman and others?
E.g.
tm_crs("+proj=ortho +lat_0=0 +lon_0=0")
Which sets the crs for the whole plot, so users don't have to figure other which shape is the main shape.
If we do it this way, a follow-up: what to do with the bounding box? tm_bbox ? Or a combined element tm_plot(crs = ..., bbox = ...)
Also I/we need to improve the spatial manipulation. Probably we can make use of s2 much more. Also tmaptools::bbis still used a lot in tmap, but it is outdated so needs an update.