Skip to content

Instantly share code, notes, and snippets.

View arbakker's full-sized avatar

Anton Bakker arbakker

  • Kadaster
  • Apeldoorn
View GitHub Profile
@arbakker
arbakker / README.md
Last active September 16, 2022 14:10
Koppel waterschappen en CBS gemeentes en provincies aan BAG woonplaatsen #pdok #ogr2ogr #spatialite #gpkg #bash #bag #intersects #csv #xmlstarlet

Koppel BAG woonplaatsen aan waterschappen en CBS gemeentes en provincies

Draai het script om de waterschappen te koppelen met woonplaatsen, door middel van een Intersects join. Het resultaat van dit script is een data.gpkg bestand met de volgende laag:

  • woonplaatsen uit de BAG WFS), gekopppeld met:
    • hwh/eenheden, in attributen waterschappen_{namen,codes} (woonplaats kan in meerdere waterschappen liggen)
    • woonplaatsen CBS in attributen {gemeente,provincie,landsdeel}_{naam,code}

Draai het script met:

@arbakker
arbakker / script.py
Created September 1, 2022 19:09
Improved script to split multipart resposnse (WIP)
import re
import os
import argparse
def split_multipart(input_file, output_dir="./"):
with open(input_file, mode="rb") as tf:
count = 0
t_byte = tf.read(1)
string_buffer = ""
@arbakker
arbakker / README.md
Created August 26, 2022 16:08
MapServer WCS 2.0.1 GetCoverage request results in corrupt geotiff

MapServer WCS 2.0.1 GetCoverage request results in corrupt geotiff

I ran into the following curious issue; a WCS 2.0.1 GetCoverage request results in a corrupt geotiff file, while a WCS 1.0.0 GetCoverage result in a valid geotiff file.

This only occurs when running the pdok/mapserver-docker image, I could not reproduce it with the camptocamp/docker-mapserver image.

This behaviour can be seen by running the do-get-cov-req.sh script from the arbakker/ahn3-wcs-invalid-geotiff-issue repo, this issues GetCoverage request against https://service.pdok.nl/rws/ahn3/wcs/v1_0:

@arbakker
arbakker / script.sh
Created August 12, 2022 12:18
Bash script to inspect timouts occuring op WCS service #bash #curl #parallel
#!/usr/bin/env bash
URL="https://service.pdok.nl/rws/ahn3/wcs/v1_0?version=2.0.1&request=GetCoverage&service=WCS&CoverageID=ahn3_05m_dtm&crs=http%3A%2F%2Fwww.opengis.net%2Fdef%2Fcrs%2FEPSG%2F0%2F28992&format=image%2Ftiff&scalesize=x%281493%29%2Cy%28808%29&subset=x%28114021.98659130755%2C121802.44239326802%29&subset=y%28487095.239434995%2C491336.6998494373%29"
COUNT=0
RESULT_FILE=$(mktemp)
function do_request(){
REQ_NR="$1"
echo ""
echo "req_nr - $REQ_NR, url - $URL"
curl "$URL" --max-time 15 -o /dev/null
@arbakker
arbakker / script.py
Created August 12, 2022 07:14
Python script to parse WCS 1.1.0 capabilities document with OWSLib #wcs #monkeypatch #owslib #python
from owslib.wcs import WebCoverageService
from owslib.wcs import wcs110
from types import MethodType
import logging
import requests
import json
@arbakker
arbakker / README.md
Last active August 10, 2022 15:04
QGIS lyr file to visualize the orientation of vertices in a polygon #QGIS #LYR #polygon #style

README

QGIS lyr file to visualize the orientation of vertices in a polygon.

image

@arbakker
arbakker / README.md
Last active August 17, 2022 15:35
QGIS processing algorithm that forces counter-clockwise orientation of polygon geometries in Geopackage file #qgis #processing #gpkg #pdok

PDOK Geometry Orientation Fixer QGIS Processing Tool

QGIS processing tools for joining PDOK AHN3 WCS (elevation) data with point data.

Tested with QGIS version 3.18, will most likely work with all QGIS version 3.X.

Installation

  1. Download pdok_geom_orientation_fixer.py
  2. Open the QGIS Processing Toolbox and click Add Script to Toolbox... and browse to the downloaded pdok_geom_orientation_fixer.py file:
@arbakker
arbakker / README.md
Last active June 28, 2022 09:52
Benchmark script to test response time duration of a WCS service #wcs #bash #gnuparallel #pdok #geotiff #ogc #gnuplot #csv

README

To run benchmark run:

./run-benchmarks.sh

See ./run-benchmarks.sh script for parameters used for benchmark runs.

@arbakker
arbakker / script.sh
Created June 7, 2022 14:48
Retrieve geojson course layout udisc #discgolf #geojson #jq
#!/usr/bin/env bash
set -e
COURSE_ID=immerloo-park-6pMm
curl -s "https://udisc.com/courses/${COURSE_ID}/map" |
pup "body script:first-of-type text{}" | cut -d= -f2 |
jq '[.courseDirectory.course.holes | to_entries[] | (.value.pathConfigurations[0] as $path | ({type: "Feature","geometry": {"type": "LineString","coordinates": [[($path.teePosition.longitude,$path.teePosition.latitude)], ($path.doglegs[] | [.longitude,.latitude]),[($path.targetPosition.longitude,$path.targetPosition.latitude)]]},"properties": {"holenr": [.key | tonumber ,1] | add}}))]' |
xargs -0 -I {} echo "{\"type\": \"FeatureCollection\",\"features\": {}}" |
jq
@arbakker
arbakker / script.js
Created June 7, 2022 09:04
Get all anchors on page with extension #js #links #crawl #html
const extension = ".TIF"
console.log(
JSON.stringify(
[...document.querySelectorAll("a")].map(
x=> x.getAttribute("href")
).filter(
x=> x.endsWith(extension)
)
)
)