'Overlay raster RGB and polygon layer in leaflet/mapview with custom CRS in R

I am trying to use R mapview/plainview or leaflet to display a raster RGB with a second layer that is a vector-based (spatial points or polygon) on top that I can toggle on an doff. It is important that both spatial layers are in polar stereographic (EPSG:3031) instead of having them reprojected to the standard EPSG:3857 web mercator projection used by leaflet. Also, I don't need to have any background tiles.

I can use planview to display a raster RGB without issue. The code is:

library(plainview)
plainview(poppendorf, r = 4, g = 3, b = 2)

However, it does not look like I can add a second-vector based layer to this. For example, I don't see a way to do something like:

plainview(poppendorf, r = 4, g = 3, b = 2) +
mapview(...)

Sticking directly with leaflet it seems I might be able to define a custom crs for 3031 here but this would likely not work with raster based leaflet functions, like addRasterRGB.

So is there a way to code such a thing in R? Preferably with the plainview package?



Solution 1:[1]

Okay a couple of things here.

  1. You should only ever have 1 thread sending messages through a socket. If you have more, you risk gabling one message by adding another message inside it. You can use a queue to send messages sequentially.

  2. Do NOT use Data streams! This is Java-only and now many years beyond its reason d'etre (it was created as a solution to the big/small endian issue - which is no longer an issue)

  3. You should put together a message standard for your communications ala how an HTTP header has information about what is being sent. I recommend using XML or JSON to structure your messages (it's how I do it over Sockets and WebSockets).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ControlAltDel