1

I downloaded a shape file from the U.S. Census and passed it through http://mapshaper.org/, which gave me a working topojson file to use in D3.

However, I realized the topojson file had all the features labels stripped. So there is no way identify features to link to CSV data.

I installed topojson, but topojson version 2 does not have the same commands as the version one to convert shape files to topojson and retain the features. Previously, topojson -o output.json input.shp This is the current topojson github reference https://github.com/topojson/topojson.

So my question is what is the best way to convert shapefiles to topojson and retain the features attributes.

4

1 回答 1

1

我将回答您使用的 mapshaper 方法。

据我了解,问题是您在转换为 topojson 时丢失了 shapefile 中包含的属性/属性,例如破坏其他文件中数据链接的功能 ID 或名称。

使用 mapshaper 时,需要将 shapefile 附带的 .dbf、.prj 和 .shp 文件复制到 mapshaper 中。.dbf 包含功能的所有属性/属性。这将确保 topojson 具有 shapefile 所具有的属性。

如果每个功能的属性太多,而您只需要其中的一个或两个,那么您可能需要使用另一个软件来执行该操作(或另一个来删除属性/属性并导出到 topojson)。

于 2017-02-14T19:03:07.143 回答