Question: When I download a large map within R (using the `OpenStreetMap` package) and I reproject the map (ideally to `+proj=longlat`), the map will always turn out distorted, making country labels etc. near the poles illegible. 

**Q1: Is there a way to obtain such a map (ideally still in R) in such a way that you can still read the labels?** Secondly, if I keep the original map (in mercator projection) but "reproject" the points, and I use the map in a (ggplot2) plot, the labels will still look strange - probably because the size of the map image changed between downloading and plotting. 

**Q2: Is there a way to either download the perfectly sized tiles or to use the original tile size in the plot, so that the labels don't look blurred?**

My code (for Q1, but Q2 is based on this as well) looks similar to this:

```
library(OpenStreetMap)
map <- openmap(c(85,-179.99999),c(-60,179.99999), zoom=2, type = "osm")
# - type="nps" is about the only type that looks okay because it has no labels
map <- openproj(map)
plot(map)

```

...and the map looks like this (if you look closely, you will see that "Brazil" is clearly visible, but "Russian Federation" (in Russian) not so much):
[![enter image description here](https://i.stack.imgur.com/BFEWT.png)](https://i.stack.imgur.com/BFEWT.png)

Answer: 
```
select (ST_Azimuth(h.vec) - ST_Azimuth(h.seg))
from (
    select 
        ST_MakeLine(cp.p, point.geom) vec,
        ST_MakeLine(cp.p, 
            ST_LineInterpolatePoint(
                line.geom, 
                ST_LineLocatePoint(line.geom, cp.p) * 1.01)
        ) seg
        from (
            select 
                ST_ClosestPoint(line.geom, point.geom)
        ) p as cp
    ) as h

```

So the idea is to calculate angle between closest line segment, and vector from closest point on the line to your point.

get a closest point on a line

```
select ST_ClosestPoint(line.geom, point.geom)

```

create the vector from closest point to your point

```
ST_MakeLine(cp.p, point.geom) vec

```

create a vector among your line

```
ST_MakeLine(
    --original point
    cp.p, 
    --find a point next to the closest point on line
    ST_LineInterpolatePoint(line.geom, 
         ST_LineLocatePoint(line.geom, cp.p) * 1.01)) seg

```

get the difference between directions

```
ST_Azimuth(h.vec) - ST_Azimuth(h.seg)

```

So right and left will be greater than zero and lower than zero.
An alternative method if you are using version 2.5.0 or later of PostGIS, you can supply a "side" argument to `ST_Buffer`. So an alternative method to the `ST_LineInterpolatePoint` with an scaled projection value is to use

```
ST_Contains(ST_Buffer(line.geom, 100, 'side=left'), point.geom)

```

One downside of this is the need to give a distance(in this case 100) to build the buffer on the left side of the LineString but in my case I already have a threshold of how close `point.geom` needs to be to be associated with `line.geom`.