0

I'm trying to use mapshaper.org to convert some geojson files to topojson, and I need the identifying properties to be preserved.

Normally this would be done with the -p flag on the command line, but despite mapshaper having the facility to allow "options from the command line interface", I can't get it to work.

I've tried -p identifier-name which give the error:

Unknown command: p

...and I've tried I've tried "-p identifier-name" in quotes following the help examples which give the error:

Unknown output option: -p identifier-name


Update: I've figured out that Mapshaper isn't passing these commands to the normal topojson tool, it's using them in its own custom command line interface, which is documented here (strangely there don't seem to be any links to this in Mapshaper itself).

In theory I want the option "id-field=nameoffield" but it doesn't seem to make any difference - all the geojson properties are still appended to the end of the file and the named property is not changed to an identifier.

How can I filter the properties in Mapshaper like I would with the command topojson in.json -o out.json -p prop1,prop2?

0

It worked with the following in Mapshaper's "command line options" box on the Export window:

"id-field=NameOfField" "drop-table"

Mapshaper doesn't pass the commands to the normal topojson tool, it has its own command line interface which is documented on the Github page here.

If there's a link to this on Mapshaper itself, I can't find it, please edit where it is into my answer!

It seems like you need to drop-table all the properties to get one to stand alone as an ID field. I can't find any way to preserve multiple properties while removing the others, or to preserve properties' names, but this works for my needs. Output looks like:

{"type":"Topology",
  "transform":{"scale":[0.XX,0.XX],"translate":[-X.XX,X.XX]},
  "arcs":[[[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],[XX,XX],...continues...
  "objects":{
     "filename":{
        "type":"GeometryCollection",
           "geometries":[
              {"arcs":[[0,1,2...]],"type":"Polygon","id":"Contents of NameOfField #0 here"},
              {"arcs":[[X,X,X...]],"type":"Polygon","id":"Contents of NameOfField #1 here"},
              ...continues...
  • Closest way to get multiple properties I've found so far is to use a composite id field with a separator, like id#_code_name in the topojson then split them out on the processing side. Not ideal but it's an option. – user568458 Mar 24 '17 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.