Created
February 11, 2022 14:26
-
-
Save leonmvd/ffb893b2cd98e9bd61d64a47075b56bc to your computer and use it in GitHub Desktop.
Calculate cbs vierkanstatistieken cell id
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
-- 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 | |
; | |
$$ language sql; | |
-- example for 500x500 grid | |
select get_cbsvierkantid(st_geomfromtext('POINT(233544.795083973 581928.166658598)'),500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment