简体   繁体   中英

TopoJSON - adding properties to a topoJSON file

New to working with TopoJSON. So I have a US counties map from the US Census site . I would simply for each state and for each state's county add the State Codes and the County Names as object properties state & county using the TopoJson CLI. I am not quite sure if this is possible or what the process or best approach is to doing that. Appreciate any help/advice.

States Result:

 {
    "type": "Topology",
    "transform": {
        "scale": [0.0006551017832872691, 0.0004481092489656037],
        "translate": [-179.23108600000003, 17.831509]
    },
    "state": "AL",
    "arcs": [
        [
            [25327, 82497],
            [0, -36],
            [-55, -24],
            [0, -24],
            [-55, -12],
            [-55, 0],
            [-109, 48],
            [0, 119],
            [55, 12],
            [0, 36],
            [54, 12],
            [55, 0],
            [55, -12],
            [0, -36],
            [55, -24],
            [0, -59]
        ]
]
} 

County's Result:

        "county": "countyname",
        "arcs": [
            [573, 574, 575, 576, 577, 578, 579]
        ]

I'm not sure that this feasible using the TopoJSON CLI, but if you treat this as if it were any other JSON, you can easily generate the fields that want and add them to your TopoJSON. I actually recently did this in Python with TopoJSON and also in JavaScript on the front end. The latter was not pretty, but it did work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM