See my comments:
library(tmap)
library(spData)
# st_transform does not support wintri ...---------------------------------
w2 = sf::st_transform(world, crs = "+proj=wintri")
#> Warning in CPL_crs_from_proj4string(x): GDAL cannot import PROJ.4 string
#> `+proj=wintri': returning missing CRS
#> OGR: Corrupt data
#> Error in CPL_transform(x, crs$proj4string): OGR error
# ... however, st_transform_proj does -------------------------------------
w3 = lwgeom::st_transform_proj(world, crs = "+proj=wintri")
#> Linking to GEOS 3.6.1, GDAL 2.2.4, proj.4 4.9.3
# it could be plot using sf::plot -----------------------------------------
plot(st_geometry(w3))

# but not using tmap ------------------------------------------------------
tm_shape(w3) + tm_polygons()
#> OGR: Corrupt data
#> Error in CPL_area(st_geometry(x)): OGR error
Created on 2018-07-10 by the reprex package (v0.2.0).
Thanks! I knew about the problems with the "wintri" projection, but didn't knew the lwgeom alternatives.
It should work now. I also made the helper functions from tmaptools more robust. See https://github.com/mtennekes/tmaptools/commit/0eb579af1c85b8b357a9e2e46193b6351cedaa80
Only the print "OGR: Corrupt data" cannot easily be suppressed.
Hmm, the lwgeom methods have problems with other projections, e.g. mercator:
all(sf::st_is_valid(world))
w4 = lwgeom::st_transform_proj(world, crs = "+proj=merc")
# Failed on geometry 7
# Error in CPL_lwgeom_transform(x, c(st_crs(x)$proj4string, crs)) :
# st_lwgeom_transform failed
w4 = sf::st_transform(world, crs = "+proj=merc")
For more info see https://github.com/r-spatial/sf/issues/509
Ok, it should work now.
In tmaptools, I've created an internal function st_transform2 which first tries st_transform and than st_transform_proj.
Please reopen if needed.
Most helpful comment
Ok, it should work now.
In tmaptools, I've created an internal function st_transform2 which first
tries st_transformand thanst_transform_proj.Please reopen if needed.