问题
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.
回答1:
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
回答2:
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
.
来源:https://stackoverflow.com/questions/17621457/adding-external-properties-to-topojson-file-of-counties