2

I am using Vincent to plot county level map for US. Took example data for 2016 elctions. It however doesnt plot for some states like California. I have checked data and FIPS codes seems to exist but still showing blank there. Any ideas what may be going on? I got county data from topo.json.enter image description here

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()
Andrew
  • 13,757
  • 13
  • 66
  • 84
ks2882
  • 191
  • 1
  • 6

1 Answers1

1

The FIPS codes for counties in the first ~7 states alphabetically need to be zero-padded to 5 characters.

Arapahoe County, CO has FIPS code 8005, which is represented as "08005" in https://raw.githubusercontent.com/jgoodall/us-maps/master/topojson/county.topo.json

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