【问题标题】:Missing States in creating county map visuals using Python3 Vincent Vega使用 Python3 Vincent Vega 创建县级地图视觉效果的缺失州
【发布时间】:2017-05-05 01:39:23
【问题描述】:

我正在使用 Vincent 为美国绘制县级地图。以 2016 年选举的数据为例。然而,它并不适用于加利福尼亚等一些州。我检查了数据,FIPS 代码似乎存在,但仍然显示为空白。任何想法可能会发生什么?我从 topo.json.获得县级数据

geo_data_c2 = [{'name': 'counties',
         'url': county_topo,
         'feature': 'us_counties.geo'}]

vis_election_counties = vincent.Map(data=merged, geo_data=geo_data_c2, scale=1000,
              projection='albersUsa', data_bind='per_dem',
              data_key='combined_fips', map_key={'counties': 'properties.FIPS'})



#Change our domain for an even inteager

vis_election_counties.scales['color'].domain = [0,1]
vis_election_counties.legend[![enter image description here][1]][1](title='per_dem')
vis_election_counties.to_json('vega.json')



vis_election_counties.display()

【问题讨论】:

    标签: maps topojson vega vincent


    【解决方案1】:

    前 7 个州的县的 FIPS 代码按字母顺序需要用零填充到 5 个字符。

    科罗拉多州阿拉帕霍县的 FIPS 代码为 8005,在 https://raw.githubusercontent.com/jgoodall/us-maps/master/topojson/county.topo.json 中表示为“08005”

    merged['combined_fips'] = merged['combined_fips'].map(lambda i: str(i).zfill(5))
    

    【讨论】:

      猜你喜欢
      • 2012-12-06
      • 1970-01-01
      • 2020-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-04
      • 2013-12-30
      相关资源
      最近更新 更多