编辑/更新——我从来没有弄清楚错误信息,但是新的一天,再试一次,这篇文章有帮助:如何将属性添加到 topojson 文件?
和它结婚的方法是这样的,添加第二个NAME
topojson -o output.json --id-property=NAME,NAME -p -e counties.csv CountiesTopo.json
我有一个很好的 topojson,显示了乔治亚州的所有县。它加载,显示正常。我使用 shpescape.com 从 .shp 转换它
但!我想将它与一些外部属性混合,每个县的毕业率存储在 .csv 中。所以我在命令行尝试 topojson 。
GaCountiesTopo.json 有一个名为 NAME 的字段;数据大写。counties.csv 有一个名为 NAME 的字段;数据大写。
我试过这个:
topojson \
-o output.json \
-e counties.csv \
-- id-property=NAME \
-p \
-- CountiesTopo.json
得到了这个:
fs.js:427
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory 'NAME'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at inputJson (/usr/local/lib/node_modules/topojson/bin/topojson:218:30)
at pop (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:28:14)
at Object.q.defer (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:59:11)
at /usr/local/lib/node_modules/topojson/bin/topojson:164:5
at Array.forEach (native)
at Object.<anonymous> (/usr/local/lib/node_modules/topojson/bin/topojson:163:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
没有这样的文件或目录'NAME',是吗?这是我的语法错误吗?或者字段名称“NAME”是否可能由于某种原因没有一对一匹配?或者,也许 .json 中有一个孤独的县,在 .csv 中没有对应的县,就像我试图将 Screven 与 Scerven 相匹配?159个县!
嗯..也许我的输入,CountiesTopo.json 搞砸了?所以,让我们试试这个,看看会发生什么:
-o output.json \
-p \
-- CountiesTopo.json
好吧,我将 output.json 插回到我的 d3 代码中,它给了我一张精简的地图:只是佐治亚州的轮廓:没有县!
所以嗯……要更多地探索 topojson,为什么不尝试转换我的原始 .shp?
-o output.json \
-p \
-- input.shp
给我:
Trace: { [Error: ENOENT, open 'input.dbf'] errno: 34, code: 'ENOENT', path: 'input.dbf' }
at output (/usr/local/lib/node_modules/topojson/bin/topojson:232:29)
at notify (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:49:26)
at EventEmitter.<anonymous> (/usr/local/lib/node_modules/topojson/node_modules/queue-async/queue.js:39:11)
at EventEmitter.emit (events.js:95:17)
at EventEmitter.ended (/usr/local/lib/node_modules/topojson/node_modules/shapefile/index.js:32:38)
at EventEmitter.emit (events.js:95:17)
at ReadStream.error (/usr/local/lib/node_modules/topojson/node_modules/shapefile/file.js:68:13)
at ReadStream.EventEmitter.emit (events.js:95:17)
at fs.js:1500:12
at Object.oncomplete (fs.js:107:15)
我的输入有问题,嗯?FWIW 这是美国人口普查老虎形状文件。
你怎么看?我怎样才能将我的 .csv 与我的 .json 结合起来?
谢谢!