Pages

Monday, February 17, 2020

Convert Dutch RD coordinates to WGS-84

Some weeks ago, I found this great Tableau formula by Rik van Schaik to convert x,y co-ordinates from the Dutch Rijksdriehoek system to latitude, longitude.

Works great in PostgreSQL to:

 -- Based on a Tableau calculated field formula by Rik Van Schaik
 -- Added more decimals for precision
 -- Rewritten for PostgresSQL
 -- Replace x & y by field names of your choice
 -- feb-2020 aukema.org

select
 52.15517440 + ((
 (3235.65389 * ((y - 463000) * 10 ^ -5)) + 
 (-32.58297 * ((x - 155000) * 10 ^ -5) ^ 2) + 
 (-0.2475 * ((y - 463000) * 10 ^ -5) ^ 2) + 
 (-0.84978 * ((x - 155000) * 10 ^ -5) ^ 2 * ((y - 463000) * 10 ^ -5)) + 
 (-0.0655 * ((y - 463000) * 10 ^ -5) ^ 3) + 
 (-0.01709 * ((x - 155000) * 10 ^ -5) ^ 2 * ((y - 463000) * 10 ^ -5) ^ 2) + 
 (-0.00738 * ((x - 155000) * 10 ^ -5)) + 
 (0.0053 * ((x - 155000) * 10 ^ -5) ^ 4) + 
 (-0.00039 * ((x - 155000) * 10 ^ -5) ^ 2 * ((y - 463000) * 10 ^ -5) ^ 3) + 
 (0.00033 * ((x - 155000) * 10 ^ -5) ^ 4 * ((y - 463000) * 10 ^ -5)) + 
 (-0.00012 * ((x - 155000) * 10 ^ -5) * ((y - 463000) * 10 ^ -5))
 ) / 3600) as lat,

 5.38720621 + (( 
 (5260.52916 * ((x - 155000) * 10 ^ -5)) + 
 (105.94684 * ((x - 155000) * 10 ^ -5) * ((y - 463000) * 10 ^ -5)) + 
 (2.45656 * ((x - 155000) * 10 ^ -5) * ((y - 463000) * 10 ^ -5) ^ 2) + 
 (-0.81885 * ((x - 155000) * 10 ^ -5) ^ 3) + 
 (0.05594 * ((x - 155000) * 10 ^ -5) * ((y - 463000) * 10 ^ -5) ^ 3) + 
 (-0.05607 * ((x - 155000) * 10 ^ -5) ^ 3 * ((y - 463000) * 10 ^ -5)) + 
 (0.01199 * ((y - 463000) * 10 ^ -5)) + 
 (-0.00256 * ((x - 155000) * 10 ^ -5) ^ 3 * ((y - 463000) * 10 ^ -5) ^ 2) + 
 (0.00128 * ((x - 155000) * 10 ^ -5) * ((y - 463000) * 10 ^ -5) ^ 4) + 
 (0.00022 * ((y - 463000) * 10 ^ -5) ^ 2) + 
 (-0.00022 * ((x - 155000) * 10 ^ -5) ^ 2) + 
 (0.00026 * ((x - 155000) * 10 ^ -5) ^ 5)
 ) / 3600) as lon

No comments:

Post a Comment

I like interaction, thank you!

Note: Only a member of this blog may post a comment.