Skip to content

Instantly share code, notes, and snippets.

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 ivopbernardo/efecb05702ce44f2274a77ba17023268 to your computer and use it in GitHub Desktop.
Save ivopbernardo/efecb05702ce44f2274a77ba17023268 to your computer and use it in GitHub Desktop.
GeoData DareData Blog
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