Last active
February 25, 2021 11:10
-
-
Save fralc/c9c8747aca233b7e35f013abdf6bd099 to your computer and use it in GitHub Desktop.
This file contains 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
import numpy as np | |
import geohash | |
import xarray as xr | |
array = xr.DataArray(np.array([[1, 2, 3], [4, 5, 6]]), coords=[("lat", [36, 37]), ("lon", [12, 13, 14])]) | |
lat_arr, lon_arr = xr.broadcast(array.lat, array.lon) | |
f = lambda y, x: geohash.encode(y, x, 7) | |
array_geohash = xr.apply_ufunc(f, lat_arr, lon_arr, vectorize=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment