Electricitymap-contrib: Some small islands like Aruba are not displayed on map

Created on 26 Feb 2018  路  4Comments  路  Source: tmrowco/electricitymap-contrib

The simplification process contained into generate-geometries.js simplifies the geometries of the entire world by using a weight of 0.01.
This threshold is so high that some small islands like Aruba (and others from Caribbean) are simply removed from map.

With this threshold of 0.01, the generated file world.json weights 420kb.

With a threshold of 0.002, Aruba come back into map but the world.json grows up to 896kb. E-Map still display well on my computer.

The good deal would be to :

  • apply a threshold of 0.01 to all countries but Aruba.
  • apply a threshold of 0.002 for Aruba
  • merge the two previous in world.json

I tried to figure out but didn't succeed using topojson. My guess was that topojson.mergeArcs would be a could candidate for merging two topojson.

Please comment on this issue how to merge the two topojson or any other idea.

frontend 馃帹

Most helpful comment

Looking deeper into "merge" from topojson shows me that it's designed to merge some polygon into one topology. That's different from merging two distinct topologies.

I wrote a function to merge two different topologies so we can apply different simplify thresholds, for example : 0.01 for entire world and 0.001 for Aruba.

After simplifying separately, we can merge both topologies and generate world.json containing Aruba.

I just added an attribute "lessSimplify" to zones into zoneDefinitions. If it's present the zone will be simplified to 0.001 instead of 0.01. We could then add other islands that disapeared from map.

This approach seems working. I just need to clean up my code and I'll send a PR soon.

All 4 comments

Looking at the topojson simplify documentation https://github.com/topojson/topojson-simplify I think you have the right idea here. We need to apply a different threshold to Aruba while preserving the rest of the map. @maxbellec any thoughts?

Same as @systemcatch, I completely agree with the general idea. Using topojson is not always straightforward... If you don't already know it, geojson.io is a great tool, it also recognises topojson.

Looking deeper into "merge" from topojson shows me that it's designed to merge some polygon into one topology. That's different from merging two distinct topologies.

I wrote a function to merge two different topologies so we can apply different simplify thresholds, for example : 0.01 for entire world and 0.001 for Aruba.

After simplifying separately, we can merge both topologies and generate world.json containing Aruba.

I just added an attribute "lessSimplify" to zones into zoneDefinitions. If it's present the zone will be simplified to 0.001 instead of 0.01. We could then add other islands that disapeared from map.

This approach seems working. I just need to clean up my code and I'll send a PR soon.

Here is a PR to solve the issue and get back Aruba on map !

Was this page helpful?
0 / 5 - 0 ratings