Features not displayed with style_function
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- jupyter-notebook, python
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện GeoJSON của issue trong Jupyter Notebook có và không có style_function, sử dụng dữ liệu demo.json đính kèm. Theo dõi đường đi tạo kiểu của Folium GeoJson và xác minh việc hoàn tất khi các feature LineString được kết xuất với màu, độ dày, độ mờ và dashArray được yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
When loading a set of GeoJSON LineString features, they are not displayed on the Folium map in my Jupyter Notebook (GColab, as well) when using style_function. If style_function=style_functions is removed from the following code, the features are displayed correctly, even though without styling.
To Reproduce
import folium
import json
# Load the GeoJSON file
with open('demo.json') as f:
data = json.load(f)
# Create a Folium map centered on a location of your choice
m = folium.Map(location=[37.982759260869564, 23.901986296376812], zoom_start=18)
# Define a style function that changes the color of LineString features
def style_functions(feature):
color = 'red' # Change the color to your desired color or use a custom logic
return {
'color': 'blue',
'weight': 3,
'opacity': 0.7,
'dashArray': [5, 10]
}
# Add the GeoJSON data to the map with the style function applied
folium.GeoJson(data, style_function=style_functions).add_to(m)
# Display the map
m
Demo GeoJSON has been attached. Please remove the .txt extension for it to load.
demo.json.txt
Expected behavior
style_function should not hide the features, but display them with the styling specified.
Environment (please complete the following information):
- Browser [e.g. firefox]
- Jupyter Lab & Google Colab
- Python 3.10.12
- folium 0.14.0
- branca 0.6.0
Additional context
In a similar test, PointString features were correctly displayed, with or without the style_function argument.
- Ngôn ngữ chính
- Python
- Star
- 7.4k
- Fork
- 2.3k
- Merge trung bình
- 17 giờ 22 phút
- Pull request đã merge (30 ngày)
- 11
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-visualization/folium
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python-visualization/folium#2092 · 5 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
python-visualization/folium#2278 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
python-visualization/folium#2259 ·
-
Map output from OSM returns blocked tiles, due to defective request or not following referer-policy Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
python-visualization/folium#2236 · 5 bình luận · 1 reaction ·
-
Touch Screen often fails Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
python-visualization/folium#2219 · 2 bình luận ·
Tất cả issue của python-visualization/folium
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
anthropics/skills#1811 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
speaches-ai/speaches#678 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
datalayer/mcp-compose#42 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
conda-forge/spacy-feedstock#177 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
UKGovernmentBEIS/inspect_evals#2523 ·