Skip to content

Instantly share code, notes, and snippets.

View arbakker's full-sized avatar

Anton Bakker arbakker

  • Kadaster
  • Apeldoorn
View GitHub Profile

Metadata


Waarom publiceren we metadata

  • Context NSDI (National Spatial Data Infrastructure)
  • Geonovum is the National Spatial Data Infrastructure (NSDI) executive committee

An SDI is a coordinated series of agreements on technology standards, institutional arrangements, and policies that enable the discovery and use of geospatial information by users and for purposes other than those it was created for.[^1]

@arbakker
arbakker / wcs-getcoverage-request.py
Created May 9, 2023 15:26
Python script to create WCS GetCoverage request with OWSLib #owslib #python #wcs #ahn #raster
#!/usr/bin/env python3
from owslib.wcs import WebCoverageService
def main():
x = 191313.0
y = 440283.3 # coordinaten in RD/EPSG:28992 van een locatie in NL
origin = [10000,618750] # origin van ahn3 coverage in RD/EPSG:28992
cell_size = 0.5 # cell size van ahn3 coverage
bbox_size = 50 # in meters - dit is formaat van coverage dat opgehaald wordt
bbox_size_pixels=bbox_size/cell_size
@arbakker
arbakker / _CSW Test NGR.md
Last active March 22, 2023 13:30
Test script en data voor het testen van de werking van de CSW service in het NGR

CSW Test NGR

Test script en data voor het testen van de werking van de CSW service in het nationaalgeoregister.nl (NGR).

Depends on csw-client.sh.

Run ./test.sh to test CSW publication in NGR.

@arbakker
arbakker / script.sh
Created February 8, 2023 14:16
check if layers in geopackage are within bbox #bash #geopackage #ogr/gdal
#/usr/bin/env bash
layer_count=0
for file in *.gpkg;do
while read -r layer;do
echo "$layer"
count=$(ogrinfo $file -sql "select count(*) as count_outside from ${layer} where not Intersects(geom, BuildMbr(3419623.11185873579233885, 3033416.80487128812819719, 4526147.91013043466955423, 3477617.21156968083232641, 3035))" | grep "count_outside.*=" | cut -d= -f2)
if [[ count -ne 0 ]];then
echo "${count} features outside Netherlands in ${file}/${layer}"
else
echo "... ${count} features outside Netherlands in ${file}/${layer}"
@arbakker
arbakker / reproject-gml.py
Created February 1, 2023 20:19
Reproject GML geometries by naively grepping GML file on <gml:poslist> , inserting geometries in GPKG, running transform query in GPKG and writing back <gml:poslist> to GML file #python #gml #fiona #wkt #ogr #xml
#!/usr/bin/env python3
import re
import os
import sys
import tempfile
from shapely.geometry import mapping, Polygon
import fiona
from fiona.crs import from_epsg
from osgeo import ogr
import lxml.etree as etree
@arbakker
arbakker / README.md
Last active January 21, 2023 23:43
Spatialite ST_IsPolygonCCW Issue

Spatialite ST_IsPolygonCCW Issue

To reproduce the issue use this GeoPackage containing 6 geometries (valid) with a counterclockwise (CCW) winding order.

Description: When determining polygon winding order for the set of geometries in the provided GeoPackage the function ST_IsPolygonCCW returns 0 for all geometries while it should return 1. The function ST_IsPolygonCW does produce the correct result

The winding order of the polygons can be visualized with the following QGIS Layer definition file, which shows the winding order of the polygons is in fact CCW (warning: this QGIS style uses a geometry generator, which is quite computionally heavy when viewing larger geometries):

image

@arbakker
arbakker / diff-svc.sh
Created December 23, 2022 07:42
Compare WMS/WFS #bash #diff #wms #wfs
#!/usr/bin/env bash
set -uo pipefail
DATASET=${1:-BAG}
GREEN=$'\e[0;32m'
YELLOW=$'\e[0;33m'
NC=$'\e[0m'
function no_diff_message(){
req_type="$1"
@arbakker
arbakker / script.sh
Created December 13, 2022 16:46
Check broken links markdown
#!/usr/bin/env bash
# npm install --save-dev markdown-link-check -g
total=0
broken=0
rm -f broken-links.log
for file in $(find . -type f -name "*.md" | grep -v ".gitea")
do
file=$(realpath $file)
logging=$(markdown-link-check --verbose "$file" 2>&1)
@arbakker
arbakker / README.md
Last active November 24, 2022 15:38
Bookmarklet NGR CSW GetRecord #ngr #geonetwork #csw #js #bookmarklet

Bookmarklet NGR CSW GetRecord

To use the bookmarklets save the JavaScript snippets as bookmarks (copy paste the JavaScript snippet in the URL field) in your browser.

image

Then use the bookmarklets by opening the bookmark:

image

@arbakker
arbakker / gen-random-points-geojson.py
Last active October 4, 2022 11:40
Generate featurecollection with random points within bounding box and random atttribute values #geojson #python #click #mock #testing
#!/usr/bin/env python3
import os
import json
from pathlib import Path
import random
import uuid
import click
def get_random_word():