Skip to content

Instantly share code, notes, and snippets.

@robinkraft
Last active August 29, 2015 14:03
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 robinkraft/1a7744f46831cc7a6189 to your computer and use it in GitHub Desktop.
Save robinkraft/1a7744f46831cc7a6189 to your computer and use it in GitHub Desktop.
working with rasterio and Apache Spark
>>> '''launch python repl with ./bin/pyspark'''
'launch python repl with ./bin/pyspark'
>>> import rasterio as rio
>>>
>>> def img_size(path):
... with rio.drivers():
... with rio.open(path) as img:
... return [img.width, img.height]
...
>>>
>>> f = sc.textFile("tifs.txt")
>>> wc = f.map(img_size)
>>> wc.collect()
[[4800, 4800], [4800, 4800], [4800, 4800]]
/tmp/Hansen_GFC2013_lossyear_50N_080W.tif
/tmp/Hansen_GFC2013_lossyear_60N_040E.tif
/tmp/Hansen_GFC2013_lossyear_60N_050E.tif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment