Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💡 [REQUEST] - Minify geojson files #97

Closed
2 of 4 tasks
ggordn3r opened this issue Aug 22, 2023 · 0 comments · Fixed by #105
Closed
2 of 4 tasks

💡 [REQUEST] - Minify geojson files #97

ggordn3r opened this issue Aug 22, 2023 · 0 comments · Fixed by #105
Assignees
Labels
dev 🦍 Development Team enhancement 🪄 New feature or request good first issue 🤝 Good for newcomers high priority 🫡 High Priority perf 🏃 Issues or enhancements related to the performance

Comments

@ggordn3r
Copy link
Collaborator

ggordn3r commented Aug 22, 2023

Start Date

8/21/23

Implementation PR

No response

Reference Issues

No response

Summary

Several of the geojson files we use are needlessly detailed and slowing down performance. There are two basic ways to reduce a spatial file:

  1. Dissolve many polygons into fewer polygons (sometimes just one), eliminating internal lines.
  2. Simplify lines by removing points that don't make a discernable difference at our map's scale. In some cases that can be 90% or more!

In the examples section I list several geojson files that could benefit from one or both of these treatments. For dissolve, you can use built-in geopandas (Python, see link above). For simplifying lines, I recommend Visvalingam’s algorithm, which is not implemented in geopandas, but is in this handy online interface: https://mapshaper.org/

Basic Example

I think it's possible to reduce files <= 4 MB down to 250 KB or less, and the hydro file to < 1 MB with minimal loss of visual detail.

Drawbacks

We may lose a bit of visual detail, but in theory the loading time and lagginess would be cut by 40%--well worth the tradeoff.

Unresolved questions

We are trying to preserve final.geojson at maximum detail, but it is the biggest file (23 MB). If performance problems persist, we may need to reduce that as well.

@ggordn3r ggordn3r added enhancement 🪄 New feature or request good first issue 🤝 Good for newcomers dev 🦍 Development Team high priority 🫡 High Priority perf 🏃 Issues or enhancements related to the performance labels Aug 22, 2023
@github-actions github-actions bot added the triage 🏥 Needs attention label Aug 22, 2023
@kmal808 kmal808 removed the triage 🏥 Needs attention label Aug 28, 2023
@Hooobot Hooobot self-assigned this Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment