0

I am having trouble merging a csv with a topojson file.

I want to add the rate column to the topojson file as a property.

My csv is like this:

index,id,county,rate,error
1,1001,"Autauga County, Alabama",12.1,1.8
2,1003,"Baldwin County, Alabama",13.9,1.2
3,1005,"Barbour County, Alabama",26.7,2.6

My topojson is a standard us county map:

{"type":"Topology",

"objects":{"counties":

{"type":"GeometryCollection","bbox":[-179.1473399999999,17.67439566600018,179.7784800000003,71.38921046500008],

"geometries":[

{"type":"MultiPolygon","id":53073,"arcs":[[[0,1,2]]]},{"type":"Polygon","id":30105,"arcs":[[3,4,5,6,7,8]]},

I am trying the following command:

topojson -o final.json -e county_level1.csv --id-property=id,id -p id,rate=rate -- us.json

But it's just deleting the id property from the topojson file.

This is a related question at this one, but with an updated attempt at resolution.

Community
  • 1
  • 1
Union find
  • 7,759
  • 13
  • 60
  • 111

1 Answers1

0

I ended up using Mike Bostock's US-Atlas, then using the following makefile:

topo/us-counties-10m-ungrouped.json: shp/us/counties.shp
    mkdir -p $(dir $@)
    node_modules/.bin/topojson \
        -o $@ \
        --no-pre-quantization \
        --post-quantization=1e6 \
        --id-property='+FIPS' \
        --external-properties=county_level1.csv \
        --properties="county=county" \
        --properties="rate_2006=+rate_2006" \
        --properties="rate_2008=+rate_2008" \
        --properties="rate_2010=+rate_2010" \
        --properties="rate_2012=+rate_2012" \
        --properties="rate_2013=+rate_2013" \
        --properties="error_2013=+error_2013" \
        --properties="attainment_2006=+attainment_2006" \
        --properties="attainment_2008=+attainment_2008" \
        --properties="attainment_2010=+attainment_2010" \
        --properties="attainment_2012=+attainment_2012" \
        --properties="attainment_2013=+attainment_2013" \
        --properties="snap_2006=+snap_2006" \
        --properties="snap_2008=+snap_2008" \
        --properties="snap_2010=+snap_2010" \
        --properties="snap_2012=+snap_2012" \
        --properties="snap_2013=+snap_2013" \
        --properties="single_2006=+single_2006" \
        --properties="single_2008=+single_2008" \
        --properties="single_2010=+single_2010" \
        --properties="single_2012=+single_2012" \
        --properties="single_2013=+single_2013" \
        --simplify=7e-7 \
        -- $<
Union find
  • 7,759
  • 13
  • 60
  • 111