我有几何数据想在传单中绘制。 在我的几何列中,一行是几何集合,包含一条线和一些点,另一行仅包含点。 我知道如果只是线/点,我可以使用 addPolylines/addMarkers。
如何在传单中绘制这两种几何形状?
我的数据:
structure(list(combination = c(1, 2), geometry = structure(list(
structure(list(structure(c(1.00223626569548, 52.8556265508789
), class = c("XY", "POINT", "sfg")), structure(c(1.00326623395723,
52.8573368002252), class = c("XY", "POINT", "sfg")), structure(c(1.00429620221897,
52.8566371609111), class = c("XY", "POINT", "sfg")), structure(c(1.00527520850952,
52.8586496729252), class = c("XY", "POINT", "sfg")), structure(c(1.01609106327471,
1.01909513737114, 1.01921315456779, 1.01921315456779, 52.7752838744008,
52.7755824285876, 52.775679782771, 52.7756862730421), .Dim = c(4L,
2L), class = c("XY", "LINESTRING", "sfg"))), class = c("XY",
"GEOMETRYCOLLECTION", "sfg")), structure(c(0.867595713389035,
1.00619833369932, 1.00794400647932, 1.01899857784703, 1.01899857784703,
1.07326277775903, 1.07332446856619, 1.07332446856619, 1.07390650792255,
1.07418277545098, 1.07426860613946, 1.07547291798711, 1.0765835751637,
1.07800224108829, 1.07894637866155, 52.0181779309727, 52.8610140394857,
52.8581400758993, 52.7756018997388, 52.7756051448803, 52.8668154271298,
52.8611112609685, 52.8616812795274, 52.8676314804611, 52.8611630811469,
52.8615776403463, 52.8678128235613, 52.8685576174324, 52.8612926313222,
52.8671738019108), .Dim = c(15L, 2L), class = c("XY", "MULTIPOINT",
"sfg"))), n_empty = 0L, crs = structure(list(input = "EPSG:4326",
wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World\"],\n BBOX[-90,-180,90,180]],\n ID[\"EPSG\",4326]]"), class = "crs"), class = c("sfc_GEOMETRY",
"sfc"), precision = 0, bbox = structure(c(xmin = 0.867595713389035,
ymin = 52.0181779309727, xmax = 1.07894637866155, ymax = 52.8685576174324
), class = "bbox"), classes = c("GEOMETRYCOLLECTION", "MULTIPOINT"
))), row.names = 1:2, class = c("sf", "data.frame"), sf_column = "geometry", agr =
structure(c(combination = 2L), .Label = c("constant",
"aggregate", "identity"), class = "factor"))
您应该尝试将 sf 或 sp 对象转换为 geojson 然后使用:
addGeoJSON(args)
这将显示带有标记、多边形和线条的点