0

Using topoJSON is it possible to take two properties from an input shapefile and combine them into a single property on the output topoJSON file?

For example if the feature on the original shapefile has the properties 'constituency':'34' and 'ward':'90' is it possible to concatenate these into a single id property in the output JSON file 'id':'3490'?

If not, can anyone suggest an elegant way to achieve this?

Lars Kotthoff
  • 107,425
  • 16
  • 204
  • 204
Tom P
  • 5,539
  • 1
  • 21
  • 24
  • Similar to http://stackoverflow.com/questions/18560541/ , a smooth process would be interesting to get. – Hugolpz Sep 05 '13 at 15:42
  • 1
    Yes, at the moment I'm doing it using a CSV to look up the concatenated values. It works fine though the extra step is a bit messy. I thought it might be nice to have something like ' -p id=constituency&ward ' seems like this would be a fairly common task (i've encountered the problem a couple of times now) but maybe not. – Tom P Sep 05 '13 at 15:51
  • I would love it too....... I guess the best would be [to fill a feature request](https://github.com/mbostock/topojson/issues) on Github. Bostock should be happy to implement it (if not already secretly there) – Hugolpz Sep 05 '13 at 16:00
  • Issue opened there: https://github.com/mbostock/topojson/issues/107 – Hugolpz Sep 07 '13 at 16:04
  • Github issue is showing some activity, seems Mike & al. may output some sweet solutions within days/weeks. – Hugolpz Sep 12 '13 at 21:53

1 Answers1

0

Yes! This is now possible. As of this commit -p id=constituency+""+ward will concatenate constituency and ward properties on the input file into an id property on the output file. The "" between constituency and ward coerces to strings ensuring javascript doesn't simply add two integers i.e. 30+24 gives 54 30+""+24 gives 3024.

Tom P
  • 5,539
  • 1
  • 21
  • 24