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 rasterio | |
import numpy as np | |
from skimage.graph import MCP | |
""" Adopted from Schönauer, M., Maack, J., 2021. R-code for calculating depth-to-water (DTW) maps using GRASS GIS. Zenodo. doi: 10.5281/zenodo.5638517 | |
adopted to Python by Ardo.J, 2024""" | |
# Setting Paths, Assuming that these layers are calculated outside of this code. | |
dem_path = "breached.tif" | |
slope_path = "slope.tif" |
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
""" | |
Simple script to return a dataframe with neighbourhood values, k_ring= 1 | |
""" | |
import h3 | |
import pandas as pd | |
import h3pandas | |
def get_h3_neighbour(h3_index): | |
# Get the 6 neighbors for the given H3 cell |
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 os | |
import geopandas as gpd | |
import h3pandas | |
folder_path = 'E:/DGGS_Benchmark/vectors' | |
# Get a list of all GPKG files in the folder | |
v_files = [file for file in os.listdir(folder_path) if file.endswith('.gpkg')] |
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 os | |
import geopandas as gpd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
folder_path = 'E:/DGGS_Benchmark/vectors' | |
# Get a list of all GPKG files in the folder | |
v_files = [file for file in os.listdir(folder_path) if file.endswith('.gpkg')] |
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 geopandas as gpd | |
import rasterio | |
import numpy as np | |
from rasterio.transform import from_bounds | |
# Function to apply majority rule cellular automaton | |
def majority_rule(array): | |
# Create a copy of the array to store the updated values | |
new_array = np.zeros_like(array) | |
rows, cols = array.shape |
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 geopandas as gpd | |
from shapely.ops import voronoi_diagram | |
from shapely.ops import unary_union | |
from shapely.geometry import shape | |
import random | |
def generate_voronoi_plot(df, n_points): | |
# Read GeoDataFrame from file | |
# Extract geometry for clipping |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Sep 6 15:28:29 2023 | |
@author: ArdoJ | |
""" | |
import click | |
from lxml import etree |
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 | |
from shapely.ops import unary_union, voronoi_diagram | |
from shapely.geometry import Polygon, MultiPolygon | |
import geopandas as gpd | |
import pandas as pd | |
def read_data(file_path): | |
return gpd.read_file(file_path) | |
def create_outline(df): |