Skip to content

Instantly share code, notes, and snippets.

View david-murr's full-sized avatar

David Murr david-murr

View GitHub Profile
ggID='put_googleID_here'
ggURL='https://drive.google.com/uc?export=download'
filename="$(curl -sc /tmp/gcokie "${ggURL}&id=${ggID}" | grep -o '="uc-name.*</span>' | sed 's/.*">//;s/<.a> .*//')"
getcode="$(awk '/_warning_/ {print $NF}' /tmp/gcokie)"
curl -Lb /tmp/gcokie "${ggURL}&confirm=${getcode}&id=${ggID}" -o "${filename}"
http://gis.stackexchange.com/questions/118682/removing-empty-geometry-with-ogr2ogr
ogr2ogr -f "ESRI Shapefile" -dialect sqlite -sql "select * from input where geometry is not null" output.shp input.shp
ogr2ogr -sql "select inshape.*, joincsv.* from inshape left join 'joincsv.csv'.joincsv on inshape.GISJOIN = joincsv.GISJOIN" shape_join.shp inshape.shp
Joining csv to shapefile
http://gis.stackexchange.com/questions/95746/join-a-csv-file-to-shapefile-using-gdal-ogr
http://www.gdal.org/ogr_sql.html
@david-murr
david-murr / gist:9d17e4b7267ab3290833
Last active December 14, 2018 22:52
command line raster stats
fio cat ../missed.shp | rio zonalstats -r amfam.vrt --categorical | jq '.features[].properties | {APN: .APN,pool: ._1}' | jq --slurp . | in2csv -f json > test.csv
jq '.features[].properties | {APN: .APN,pool: ._1}' pools.geojson | jq --slurp . | in2csv -f json > test.csv
fio cat countries.shp | rio zonalstats -r dem.tif --prefix "elevation_" > countries_with_elevation.geojson
fio cat large.shp | rio zonalstats -r elevation.tif --sequence | some-other-process
time fio cat ../parcels/parcels_pools.shp | parallel --pipe "rio zonalstats -r amfam.vrt --categorical" > out
fio cat test.shp | jq '{geometry: .geometry, PARCEL_ID: .properties.PARCEL_ID}' -c | fio collect > test.geojson
@david-murr
david-murr / gist:75b64f6935ab7443b786
Created January 24, 2016 01:11
parsing shapefiles to json -- getting slurp and the array brackets right
fio cat missed.shp | jq --slurp "[.[] | {APN: .properties.APN, pool_size: .properties.POOL_SZ}]" | in2csv -f json > test.csv