5

related question

I'm trying to add external properties to a topojson file, us-counties.json (made with us-atlas using make topo/us-counties.json). I'm working off this example. But my resulting topojson file us-counties-with-population.json has no properties at all.

My call looks like:

topojson --external-properties data.csv \
  --id-property id_county \
  --properties population=+percent_population \
  -o us-counties-with-population.json \
  -- us-counties.json

and my data looks like (head -n5 data.csv):

id_county,county_name,percent_population
01003,"Baldwin County, Alabama",9.71576144493279
01043,"Cullman County, Alabama",6.734653334216277
01051,"Elmore County, Alabama",7.095232589509385
01069,"Houston County, Alabama",9.857459440234194

I'm using topojson v1.2.2. I think I might be missing something related to how the ids are matched, but I'm not sure what it is.

Community
  • 1
  • 1
Adam Greenhall
  • 4,818
  • 6
  • 30
  • 31
  • See also : [How to add properties to topojson file?](http://stackoverflow.com/questions/18444261/) – Hugolpz Nov 01 '13 at 13:58
  • 2
    Was a solution to this particular problem ever found? I'm running into a similar problem; I can add properties fairly easily when joining a csv with a GeoJson or shp file, but when I try to join a csv with a TopoJson, no dice. I'm rather confused. – Jefftopia Feb 04 '15 at 01:51
  • I'm having the same problem a year later. – bjoseph Jan 05 '16 at 21:31

2 Answers2

0

Very nice question, I spent an hour on this problem spinning my wheels. It turns out the External Properties section provides a simple example which uses the reference id FIPS as the id.

You should be able to use your csv with one simple modification. Rename id_county to FIPS. Next specify your external resource with the -e flag.

-p name=COUNTY,name=STATE,area=+SQUARE_MIL,population=+percent_population  -e data.csv
JZ.
  • 21,147
  • 32
  • 115
  • 192
0

This answer worked for me: How to add properties to topojson file?

In your case the call would look like:

topojson -o us-counties-with-population.json -e data.csv --id-property=id_county,id -p properties population=+percent_population -- us-counties.json

Note: I'm assuming the id-property of your topojson file is id.

Community
  • 1
  • 1
bjoseph
  • 2,116
  • 17
  • 24