Created
October 24, 2021 13:46
-
-
Save amandasaurus/12c7a23ba7a40d58c8f36a61d38d410e to your computer and use it in GitHub Desktop.
convert OSM ways into long skinny skeletons with ST_Approxipat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| # Purpose of this is to try to convert long skinny rivers like | |
| # https://www.openstreetmap.org/way/119339404#map=17/16.32108/-61.77254 into | |
| # regular OSM ways | |
| # | |
| # This code is licenced Affero GPL v3+ | |
| # | |
| # Alas, this does not appear to work very well, with the new OSM ways being | |
| # very disconnected and disjoined. This should be viewed as an experiment, and | |
| # not a way to generate OSM geometric data | |
| set -o errexit -o pipefail | |
| wget -N http://download.geofabrik.de/central-america-latest.osm.pbf | |
| if [ central-america-latest.osm.pbf -nt guadeloupe.osm.pbf ] ; then | |
| osmium extract --overwrite central-america-latest.osm.pbf -o guadeloupe.osm.pbf --bbox -62.061768,15.686510,-60.600586,16.694079 | |
| fi | |
| osmium tags-filter guadeloupe.osm.pbf --overwrite -o guadeloupe-water.osm.pbf a/waterway=riverbank | |
| osm2pgsql --latlon --hstore-all --drop -p waterway_riverbank_area guadeloupe-water.osm.pbf | |
| psql -c "CREATE EXTENSION postgis_sfcgal;" | |
| pgsql2shp -f spines.shp "select tags->'waterway', ST_ApproximateMedialAxis(way) from waterway_riverbank_area_polygon" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment