1

I'm using the cartography package in R to plot a choropleth map. However, I have a problem placing the legend, which can be placed by means of the legend.pos argument, but which always overlaps with my map. The documentation says:

legend.pos : position of the legend, one of "topleft", "top", "topright", "right", "bottomright", "bottom", "bottomleft", "left" or a vector of two coordinates in map units (c(x, y)). If legend.pos is "n" then the legend is not plotted.

(Source: https://cran.r-project.org/web/packages/cartography/cartography.pdf)

Using "right", "bottomright" etc, the legend still overlaps my map; thus, I'd like to use the coordinates version. However, I tried already lots of different combinations, but the legend does not appear in the map anymore.

My question is: How to understand "coordinates in map units"? How can I find the right coordinates to that the legend becomes visible?

Here is my code; as you can see, I use the standard "nuts0" map.

choroLayer(spdf = nuts0.spdf, df = nuts0.df, var = "cdp", 
           breaks=seq(from=0, to=240, by=40),
           col = farb, 
           colNA="grey70",
           border = "grey40", lwd = 0.5, 
           legend.pos = "bottomright",
           legend.title.txt = "No. companies",
           add = F)
  • The 'map units' will be determined by the projection system you're in. They will either be degrees:minutes:seconds or meters. I think in R you can use proj4string(spdf) to get your crs. – RoperMaps Dec 8 '17 at 15:46
1

Correct answer from RoperMaps: Get the map units by means of proj4string(nuts0.spdf)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.