-
-
Save DanielJDufour/9e15724b47ffa9296dc0902c42da3a81 to your computer and use it in GitHub Desktop.
hist.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get counts for raster using rio | |
from collections import Counter | |
import numpy as np | |
import rasterio as rio | |
from sys import argv | |
_, filepath = argv | |
with rio.open(filepath) as src: | |
bands = src.read() | |
height = len(bands[0]) | |
width = len(bands[0][0]) | |
print("height:", height, width) | |
counts = Counter() | |
for row in bands[0]: | |
counts.update(row) | |
print("counts:", counts.most_common(5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment