#!/usr/bin/env python # coding: utf-8 # # New Zealand DEM remake # # See the original notebook [here](https://nbviewer.org/github/royalosyin/Work-with-DEM-data-using-Python-from-Simple-to-Complicated/blob/master/Sup03-Ridgelines%20Map%20of%20DEM.ipynb). # In[1]: import pandas as pd from lets_plot import * # In[2]: LetsPlot.setup_html() # In[3]: def dataset_array_to_dataframe(dataset_array): df = pd.DataFrame.from_records([ (j, i, a) for i, r in enumerate(dataset_array) for j, a in enumerate(r) ], columns=["x", "y", "h"]) return df # In[4]: raw_data_array = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/new_zealand.csv", header=None).to_numpy() df = dataset_array_to_dataframe(raw_data_array) df = df[df.h > 0] print(df.shape) df.head() # In[5]: ggplot(df) + \ geom_area_ridges(aes("x", "y", height="h"), \ stat='identity', scale=.002, \ color="#08519c", fill="#bdd7e7", sampling=sampling_pick(df.shape[0]), \ tooltips='none') + \ geom_text(x=140, y=65, label="New Zealand", size=20, family="Cinzel") + \ scale_y_continuous(trans='reverse') + \ ggsize(600, 600) + \ theme_minimal() + theme(axis='blank', panel_grid='blank', \ plot_background=element_rect(color='black', fill='#e6e6e6', size=1))