如何解决通过 cex 的 Mapview pointsize 不是固定大小的映射子集或更新的数据
新年好!
实际上我想在地图上显示 CoVid19 病例。我有每个案例的地址。 我为每个案例在地图上绘制了一个点。这很好用!
有些地址有不止一个案例(例如一个家庭)。因此,我想通过 cex 选项控制点的大小。对于每张地图,这同样适用。
但是一张地图中的 cex = 1 并不自动意味着下一张地图(例如第二天)中 cex = 1 的点具有相同的大小。
我如何控制它,每个地图(天)的 cex=1 大小相同?
简单示例:
breweries1 <- breweries %>% filter(number.of.types == 1)
mapview(breweries1,cex = "number.of.types")
breweries2 <- breweries %>% filter(number.of.types < 3)
mapview(breweries2,cex = "number.of.types")
感谢您的帮助!
保持健康!
解决方法
我直接从 R-mapview
包的开发者那里得到了这个答案:
“当前 fgb 渲染模式和经典渲染模式之间存在差异,前者不考虑参数 min.rad 和 max.rad。作为一种解决方法,您可以设置 mapviewOptions(fgb = FALSE):”
library(mapview)
library(dplyr)
mapviewOptions(fgb = FALSE)
breweries1 <- breweries %>% filter(number.of.types == 1)
mapview(breweries1,cex = 10) # supply cex directly as only one size
breweries2 <- breweries %>% filter(number.of.types < 3)
mapview(breweries2,cex = "number.of.types",min.rad = 10,max.rad = 20)
为了获得更大的灵活性,我建议通过代码设置 min.rad
和 max.rad
:
mapviewOptions(fgb = FALSE)
breweries2 <- breweries %>% filter(number.of.types < 3)
cexmin = min(breweries2$number.of.types) + 1
cexmax = max(breweries2$number.of.type) + 1
mapview(breweries2,min.rad = cexmin,max.rad = cexmax)
我分别在 + 1
和 cexmax
中添加了一个 cexmin
。 cex = 1
,因为 # Groups to look for
$groups = 'Group1','Group2','Group3'
# Import users to check from a csv file
Import-Csv "$PSScriptroot\Users.csv" |
ForEach-Object {
# Get all groups that the $user is a member of
$membership = (Get-ADPrincipalGroupMembership $_.samAccountName).Name
$_ |
Select-Object *,@{Name = 'Group1'; Expression = { 'Group1' -in $membership }},@{Name = 'Group2'; Expression = { 'Group2' -in $membership }},@{Name = 'Group3'; Expression = { 'Group3' -in $membership }}
} |
Export-Csv -Path "$PSScriptroot\Users_New.csv" -NoTypeInformation
在此解决方案中非常小。
保持健康!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。