Skip to content

Instantly share code, notes, and snippets.

@celoyd
Created July 29, 2016 17:50
Show Gist options
  • Save celoyd/e7c7bfa0e88197df4cd405741a754f9f to your computer and use it in GitHub Desktop.
Save celoyd/e7c7bfa0e88197df4cd405741a754f9f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import rasterio as rio
from sys import argv
from skimage import io
import numpy as np
# Reads an image with a bunch of bands (i.e., layers on the z axis)
# and returns an image with one band, each value in which is the mean
# along the z axis at that x,y.
with rio.open(argv[1]) as src:
lidar = src.read()
flat = np.mean(lidar, axis=0)
io.imsave('flat.tif', flat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment