Created
May 5, 2022 21:39
-
-
Save ivopbernardo/efecb05702ce44f2274a77ba17023268 to your computer and use it in GitHub Desktop.
GeoData DareData Blog
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
import rasterio | |
from rasterio.plot import show | |
url = "zip+file:data/mdt.zip!mdt.tif" | |
lisbon_elevation = rasterio.open(url) | |
# Plot the raster data to get a sense of it | |
show(lisbon_elevation, cmap="terrain") | |
# Get the elevation from the raster data | |
house_data_gdf["elevation"] = ( | |
house_data_gdf | |
.to_crs(lisbon_elevation.crs) | |
.geometry | |
.apply( | |
lambda x: next(lisbon_elevation.sample([(x.x, x.y)]))[0] | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment