7 · points¶
Map.points plots an arbitrary point FeatureCollection, coloured by its first numeric column (cleopatra ScatterGlyph). Here we vectorise the DEM cell centres into a FeatureCollection.
Setup — inline plots and the path to the bundled Lisbon DEM.
In [1]:
Copied!
%matplotlib inline
from pathlib import Path
# Locate the bundled Lisbon DEM from the repo root (works from docs/ or the repo root).
ROOT = Path.cwd()
while not (ROOT / "examples" / "data" / "LisbonElevation.tif").exists() and ROOT != ROOT.parent:
ROOT = ROOT.parent
DEM = str(ROOT / "examples" / "data" / "LisbonElevation.tif")
from pyramids.dataset import Dataset
from digitalearth.static import Map
ds = Dataset.read_file(DEM)
coarse = ds.resample(ds.cell_size * 10) # downsample for legible markers/cells
from pyramids.feature import FeatureCollection
%matplotlib inline
from pathlib import Path
# Locate the bundled Lisbon DEM from the repo root (works from docs/ or the repo root).
ROOT = Path.cwd()
while not (ROOT / "examples" / "data" / "LisbonElevation.tif").exists() and ROOT != ROOT.parent:
ROOT = ROOT.parent
DEM = str(ROOT / "examples" / "data" / "LisbonElevation.tif")
from pyramids.dataset import Dataset
from digitalearth.static import Map
ds = Dataset.read_file(DEM)
coarse = ds.resample(ds.cell_size * 10) # downsample for legible markers/cells
from pyramids.feature import FeatureCollection
Build a point FeatureCollection with an elevation column and scatter it.
In [2]:
Copied!
pts = coarse.to_geodataframe(geometry="point", values=False)
pts['elevation'] = coarse.read_array(band=0).astype('float64').ravel()
fc = FeatureCollection(pts)
m = Map(crs=coarse.epsg, figsize=(9, 7))
m.points(fc)
m.colorbar(label='elevation (m)')
m.set_title('points')
m.fig;
pts = coarse.to_geodataframe(geometry="point", values=False)
pts['elevation'] = coarse.read_array(band=0).astype('float64').ravel()
fc = FeatureCollection(pts)
m = Map(crs=coarse.epsg, figsize=(9, 7))
m.points(fc)
m.colorbar(label='elevation (m)')
m.set_title('points')
m.fig;