4

I'm displaying GPX traces on a Leaflet map. I'm using TopoJSON to drastically reduce file size, which works pretty well.

My problem is the following : I want to be able to display altitude and timestamp for each point of the trace. In order to do that, I need the TopoJSON cli to keep ALL of the original coordinates, to match their indexes with indexes of the timestamps array.

But so far I'm unable to do that. On my GPX file converted to GeoJSON, I got 4062 coordinates, and the GeoJSON file converted to TopoJSON has one arc with 3913 vertices.

Using this :

togeojson trace.gpx | topojson --no-quantization -p > trace.topojson

Gives :

bounds: -18.033666 27.732765 -17.981946 27.772151 (spherical)
topology: 2 arcs, 3915 points
prune: retained 2 / 2 arcs (100%)

So, is it possible to keep the same amount of points, so that I could map precisely coordinates in the TopoJSON file and timestamps?

3

You can add the simplify-proportion option

--simplify-proportion 0.999999

The parameter represents the proportion of points being kept (https://github.com/mbostock/topojson/wiki/Command-Line-Reference), so you want it at 1. However it needs to be under 1 so you need to make it close enough to 1 (depends on your input data)

I am not sure the amount of compression you can hope for with this option plus no quantization and preserving properties. (if you do that on world-110m.json it will be bigger, but it might work for a GPS trace). I would consider keeping quantization in your case if you do have file size issues.

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.