Skip to content

Instantly share code, notes, and snippets.

@jleedev
Created May 24, 2022 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jleedev/c36fcbe5a36fab15969c8782884d2af2 to your computer and use it in GitHub Desktop.
Save jleedev/c36fcbe5a36fab15969c8782884d2af2 to your computer and use it in GitHub Desktop.
extremely normal shell script
FROM ubuntu
RUN apt-get update
RUN apt-get -y install gdal-bin
RUN apt-get -y install jq
RUN >x.csv printf 'id,WKT\n1,%s\n' "$(echo '[[0.2,0.2],[0.75,0.75],[0.25,0.75],[0.2,0.2]]' \
| jq '(2*(-1|acos)*6378137)as$c|[.[]|[(.[0]-0.5)*$c,(0.5-.[1])*$c]|join(" ")]|join(",")|"LINESTRING("+.+")"')"; \
echo EPSG:3857 >x.prj
RUN ogrinfo --version
RUN ogr2ogr -t_srs WGS84 -f GeoJSONSeq y.geojsons x.csv -dialect sqlite -sql 'select ST_Length(geometry) from x'
RUN <y.geojsons jq '(2*(-1|acos)*6378137)as$c|.properties."ST_Length(geometry)"/$c'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment