2

編集/更新 - エラーメッセージがわかりませんでしたが、新しい日、もう一度やり直してください。この投稿は役に立ちました:プロパティを topojson ファイルに追加する方法?

結婚する方法はこれでした、2番目の名前を追加します

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」が 1 対 1 で一致していない可能性はありますか? それとも、.csv に対応するものがない .json のどこかに孤独な郡があるのでしょうか? 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 に結合するにはどうすればよいですか?

ありがとう!

4

0 に答える 0