Skip to content

Instantly share code, notes, and snippets.

View leonmvd's full-sized avatar

Leon leonmvd

  • University of Groningen
  • Groningen, Netherlands
View GitHub Profile
@leonmvd
leonmvd / calculate_cbs_vierkanstatistieken_cell_id.sql
Created February 11, 2022 14:26
Calculate cbs vierkanstatistieken cell id
-- function that calculates the CBS Vierkantstatistieken grid cell for point coordinates in RD new.
create or replace function get_cbsvierkantid(fn_geom geometry, i_dist int) returns text as $$
select
'E' ||
((st_x(fn_geom)::numeric - (st_x(fn_geom)::numeric % i_dist)) / 100)::int ||
'N' ||
((st_y(fn_geom)::numeric - (st_y(fn_geom)::numeric % i_dist)) / 100)::int
as cbs_vierkant_id
;
@leonmvd
leonmvd / rectangle_equal_splitter.sql
Created January 8, 2019 10:09
Rectangle splitter for Postgis
-- blades part adapted from "https://gis.stackexchange.com/questions/104439/how-to-extend-a-straight-line-in-postgis"
with medialaxis_multi as(
select
polygons.id,
st_union(ST_ApproximateMedialAxis(geom)) as geom
from
polygons
group by
polygons.id
),