+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

暂无数据

GeoPandas: How to plot hexagon geometry?

发布于2021-03-08 20:57     阅读(808)     评论(0)     点赞(15)     收藏(5)


0

1

2

3

4

5

6

7

I have a geopandas dataframe with hexagon geometry and a label and I am having trouble figuring out how to:

  1. plot the hexagons with my own color scheme
  2. show the legend

a snippet of the data looks like:

    geometry    pred_labels color
0   POLYGON ((63.06967 29.61571, 63.07798 29.60487...   1   0.000000
1   POLYGON ((63.18163 29.99343, 63.18998 29.98255...   3   0.666667
2   POLYGON ((62.99624 29.69126, 63.00458 29.68042...   1   0.000000
3   POLYGON ((63.32191 29.58779, 63.33018 29.57693...   1   0.000000
4   POLYGON ((63.64046 29.59359, 63.64869 29.58271...   1   0.000000

10509 rows × 3 columns

when I plot:

df_january.plot(cmap='Purples', legend=True);

pic

I get something that appears right, but if I specify column to pred_labels or color, I will get very wonky and messed up plots. For instance:

df_january.plot(column='pred_labels', cmap='Purples', legend=True);

enter image description here

Zoomed in more:

enter image description here


解决方案


Following J.Warren, placing the geometry column at the end of the df improved plotting.

0

1

2

3

4

5

6



所属网站分类: 技术文章 > 问答

作者:黑洞官方问答小能手

链接: https://www.pythonheidong.com/blog/article/880003/f8b4055e34f83d74dc18/

来源: python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

15 0
收藏该文
已收藏

评论内容:(最多支持255个字符)