Leaflet for non-geographic data (Cartesian coordinates) from R
I am trying to create an interactive plot with a flyer containing polygons. The coordinates of these polygons are not longitude / latitudes, but rather the Cartesian x and y coordinates that represent the floor plan of the building.
For coordinates that are single digits, the results look good:
library(leaflet)
library(sp)
Sr1 = Polygon(cbind(c(9, 8, 8, 9, 9),
c(3, 3, 4, 4, 3)))
Srs1 = Polygons(list(Sr1), "s1")
SpP = SpatialPolygons(list(Srs1), 1L)
leaflet() %>% addPolygons(data = SpP)
But when I increase all y-coordinates by 100, things go wrong:
library(leaflet)
library(sp)
Sr1 = Polygon(cbind(c(9, 8, 8, 9, 9),
c(103, 103, 104, 104, 103)))
Srs1 = Polygons(list(Sr1), "s1")
SpP = SpatialPolygons(list(Srs1), 1L)
leaflet() %>% addPolygons(data = SpP)
I am assuming this is due to the default projection settings on the map. I tried to initialize the map with these settings:
leaflet(options(crsClass = "L.CRS.Simple"))
After reading this example, but no success.
+3
source to share
No one has answered this question yet
Check out similar questions: