# define temporary geojson for mapshaper to export to
json=$(mktemp --suffix .geojson)
# simplify your shapefile and save to tmp geojson
mapshaper example.shp -simplify 1% cartesian -o format=geojson $json
# remove null features from tmp geojson with jq
cat $( echo $json | sed 's:[.]geojson$:-ms.geojson:g') |\
jq '.|[.features[]|select(.geometry.type != null)]' |\
# add back JSON for features - I am positive jq can do this better than sed! just haven't gotten it yet
sed '1 i\{"features":' |\
sed '$ s:$:,:g;$ s:$:"type"\:"FeatureCollection"}:g'
Last active
August 29, 2015 14:24
-
-
Save albert-decatur/d215db83dca806bc9c46 to your computer and use it in GitHub Desktop.
simplify shapefile, convert to geojson, remove null features
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment