Skip to content

Instantly share code, notes, and snippets.

View breinbaas's full-sized avatar

Rob van Putten breinbaas

View GitHub Profile
"""
Script documentation
Get all BRO cpt's from the current ArcGis Map extent. Add the script to your toolbox.
And make sure to add three parameters;
Output Path [Folder]: where to write the cpts to
Start Date [Date]: start date CPT (NOT before 01-01-2015)
End Data [Date]: end date CPT
from typing import List
def line_to_id(line: str) -> str:
"""Extract the id from the line
We expect the id to be between '', the rest of the line should not contain the ' character
Note that we do an extra check to see if there are no spaces in the id
Args:
from pathlib import Path
import subprocess
PATH_TO_DSTABILITY_CONSOLES = "D:\\Apps\\D-GEO Suite\\Consoles\\DStabilityConsole"
def case_insensitive_glob(filepath: str, fileextension: str) -> List[Path]:
p = Path(filepath)
result = []
for filename in p.glob("**/*"):
if str(filename.suffix).lower() == fileextension.lower():
@breinbaas
breinbaas / add_tree_excavation.py
Created August 16, 2023 07:18
Basic code to add a tree as an excavation in D-Stability using the adjusted geolib version
from typing import List, Tuple
import logging
from pydantic import BaseModel
from pathlib import Path
import subprocess
import shutil
from shapely.geometry import Polygon, LineString
from shapely.ops import unary_union, orient
from geolib.models.dstability import DStabilityModel
@breinbaas
breinbaas / qgis_hwbp_score_filter.py
Last active February 15, 2024 12:25
QGIS Processing Toolbox script om snel selecties te maken in HWBP faalmechanismen en categorieen
# note, code is not clean yet so it will have some unused imports
# it expects a vectorlayer with columns like STPH, STBI, etc
# and the scores as -, Iv, IIv, IIIv, IVv, Vv, VIv, VIIv
# if will not be useful if your data is formatted differently
# but maybe then it is an inspiration for creating your own filters ;-)
#
# Rob van Putten | breinbaasnl@gmail.com | feb 2024
#
"""
from leveelogic.helpers import case_insensitive_glob
from leveelogic.deltares.dstability import DStability
# Dit script leest alle grondsoorten uit een directory met stix bestanden
# en maakt een csv bestand van de grondsoorten en de helling. Dit is nodig
# voor de leggerprofielen omdat we moeten weten welke grondsoort naam
# bij welke helling hoort
# Locatie van de stix bestanden
STIX_PATH = "Z:\\Python\\leveelogic\\tests\\testdata\\stix"
from shapely.geometry import Polygon
from shapely import intersects, get_coordinates
from shapely.ops import unary_union
import geopandas as gpd
import shapefile
# creeer wat testdata
polygoon_data = {
"A": [(0, 0), (18, 0), (18, -15), (0, -15)],
"B": [(10, 2), (15, 2), (15, -6), (10, -6)],

Godot - Python interaction

I need to call some specific Python code which is not easy to implement as Godot code and came up with this solution. Note that the essence of the script is that the Python code generates a dictionary with the required information and prints this as a JSON formatted string. Godot calls the script and receives the output and uses the internal JSON functionality to convert the string to a Godot JSON object. Also note that the Python script gets called from the python version that is set in the environment specific for this Python code (python-venv).

Not too difficult actually!

Python code

import sys