我正在尝试使用R Markdown中的Leaflet创建一个简单的地图。我使用标准差分类方法将数据分为4类。当它生成地图时,地图上的颜色看起来比应该的颜色要轻得多。这里有什么问题 ?谢谢!
library(rgdal)
library(leaflet)
library(readr)
STCOU<- readOGR("H:/SP/STCOU.shp", "STCOU", GDAL1_integer64_policy = TRUE)
UNGEOCODED <- read_csv("H:/SP/UNGEOCODED.csv")
palette1 <- colorBin(c('#f1eef6','#bdc9e1','#74a9cf','#0570b0'),bins = c(0,1600, 3400, 5200, 32000),pretty = FALSE)
palette2 <- colorBin(c('#ece7f2','#a6bddb','#2b8cbe'),bins = c(0,1816, 3821, 35781),pretty = FALSE)
popup1<-paste("2015 Ungeocoded Tallies",
"<br>GEO_ID: ",
STCOU$GEOID,
"<br>State: ",
STCOU$STATEFP,
"<br>County: ",
STCOU$COUNTYFP,
"<br>Name: ",
STCOU$NAME,
"<br>LSAD: ",
STCOU$LSAD,
"<br>CensusArea: ",
STCOU$ALAND,
"<br>Current_UNGEO_Counts: ",
STCOU$CURRENT_UN,
"<br>Fall15_UNGEO_Counts: ",
STCOU$FAL15_UNGE)
popup2<-paste("2016 Ungeocoded Tallies",
"<br>GEO_ID: ",
STCOU$GEOID,
"<br>State: ",
STCOU$STATEFP,
"<br>County: ",
STCOU$COUNTYFP,
"<br>Name: ",
STCOU$NAME,
"<br>LSAD: ",
STCOU$LSAD,
"<br>CensusArea: ",
STCOU$ALAND,
"<br>Current_UNGEO_Counts: ",
STCOU$CURRENT_UN,
"<br>Fall15_UNGEO_Counts: ",
STCOU$FAL16_UNGE)
```
### Ungeocoded 2015 2016
```{r}
leaflet() %>%
setView(lng = -94.308561, lat = 38.561161, zoom=5) %>%
addProviderTiles("Esri.WorldGrayCanvas",
options = tileOptions()) %>%
addPolygons(data=STCOU,weight=0.1,
fillColor = ~palette1(UNGEOCODED$FAL15_UNGE),
popup = popup1,
group="<span style='color: #7f0000; font-size: 11pt'><strong>2015</strong></span>")%>%
addPolygons(data=STCOU,weight=0.1,
fillColor = ~palette2(UNGEOCODED$SPR16_UNGE),
popup=popup2,
group="2016") %>%
addLayersControl(baseGroups = c("<span style='color: #7f0000; font-size: 11pt'><strong>2015</strong></span>",
"2016"), options = layersControlOptions(collapsed =FALSE))%>%
addLegend(position = 'topleft',
colors = c('#f1eef6','#bdc9e1','#74a9cf','#0570b0'),
labels = c('Low'," "," ","High"),
opacity = 0.6,
title = "2015 2016 Ungeocoded")
```
答案 0 :(得分:0)
基本上,您只需阅读传单包中各种fillOpacity
函数的文档,您将看到library(leaflet)
df <- data.frame(
lon = sample(seq(-94.9, -93.1, 0.00001), 10, replace = T),
lat = sample(seq(38.1, 39.9, 0.00001), 10, replace = T),
value = sample(density(c(0,1600, 3400, 5200, 32000))$x, 10)
)
palette1 <- colorBin(c('#f1eef6','#bdc9e1','#74a9cf','#0570b0'), bins = c(0,1600, 3400, 5200, 32000), pretty = FALSE)
leaflet(df) %>%
setView(lng = -94.308561, lat = 38.561161, zoom=7) %>%
addProviderTiles("Esri.WorldGrayCanvas") %>%
addCircleMarkers(weight=0.1,
fillOpacity = 0.7,
fillColor = ~palette1(value)
)
默认设置为0.2。这是为了在功能重叠时使您免于自己,但您可以将参数设置得更高,即
最小可重复示例+答案 - &gt;
@DatabaseTable(tableName=Order.TABLE_NAME)
public class Order extends Document {
public static final String TABLE_NAME = "order";
@DatabaseField( generatedId = true)
private int id;
@ForeignCollectionField(eager = true)
private ForeignCollection<OrderProduct> products;
private IPrepareOrder iPrepareOrder;
public Order(){
}
public int getId(){
return id;
}
public Collection<OrderProduct> getProducts(){
return products;
}
}
@DatabaseTable(tableName=OrderProduct.TABLE_NAME)
public class OrderProduct {
public static final String TABLE_NAME = "orderProduct";
@DatabaseField(generatedId = true)
private int id;
@DatabaseField(canBeNull = false, foreign = true, foreignAutoRefresh = true)
private Order order;
@DatabaseField(foreignColumnName = "id", canBeNull = false, foreign = true, foreignAutoRefresh = true)
private Product product;
public OrderProduct(){
}
public int getId(){
return id;
}
public Order getOrder(){
return order;
}
public void setOrder(Order order){
this.order = order;
}
}