-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use mapshaper to simplify a region geometry #732
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but will not reprocess the existing regions (if I understand correctly) and we can't delete them and re-add them because they already have referencing projects.
It would also be nice to see the resulting size of the simplified shape, to adjust the interval if deemed necessary. For large countries (or large provinces) the default threshold may not be enough to reduce the size enough and still hog the CPU when performing spatial queries.
scripts/population/load-regions
Outdated
# interval= Specify simplification amount in units of distance. | ||
# Uses meters when simplifying unprojected datasets in 3D space (see planar option below), | ||
# otherwise uses the same units as the source data. | ||
INTERVAL_DISTANCE=${INTERVAL_DISTANCE-1000} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please expand the comment above explaining that in our case since our GeoJSON are not projected (ie. use WGS84 coordinates) then this means the resolution for the simplified shape will be 1km? (Or at least that's what I understand from the documentation 😁)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I'm thinking this can potentially lead to legitimate providers being excluded. Maybe we should play a bit with the thresholds and the problematic countries and check the resulting sizes. We may get away with a smaller threshold. @manumoreira what was the country that triggered the original issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, a default of 100 may work fine. I'm testing locally with some datasets I have and Philipines shrinks from 58 Mb to 2.5 Mb using 100 as the threshold. That should be acceptable I think, since Kenya's contour is 4.9 Mb unprocessed and we didn't have problems with that country so far. NB. sizes are of the admin level 0 .geojson
files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The country was Mozambique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to zoom more because the difference wasn't visible from https://mapshaper.org/. It is the same island from the previous screenshots on the south east of Kenya.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparison for Mozambique at the north betwee original resolution and 100m maps
Testing files
moz-geojson.tgz. I used https://mapshaper.org/ to load them in separate layers.
I'll add a |
* Add -f to force geometry updates * Print sizes of files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment further on the task being done - I'll trust Gus' opinion on that.
* Use upsert to update region's geometry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
As a note for deployment, we'll probably need to manually fix the input file with the duplicate keys when running this in production.
-f
parameter toload-regions
to update an existing regionINTERVAL_DISTANCE=100
as default distance for simplificationCloses #727