pieterprovoost / wktmap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lambert 72 not always correctly shown?

pietercolpaert opened this issue · comments

For example, this Lambert72 is slightly shifted

<http://www.opengis.net/def/crs/EPSG/9.9.1/31370> POLYGON ((91368.34 185853.08, 91367.36 185853.07, 91366.4 185853.26, 91365.49 185853.62, 91364.67 185854.16, 91363.97 185854.85, 91363.42 185855.66, 91363.04 185856.56, 91362.84 185857.52, 91362.83 185858.5, 91363.01 185859.47, 91363.38 185860.37, 91363.92 185861.19, 91364.61 185861.89, 91365.42 185862.44, 91366.32 185862.83, 91367.28 185863.02, 91372.04 185863.53, 91372.14 185863.53, 91372.23 185863.55, 91388.83 185864.69, 91392.43 185864.93, 91396.17 185865.21, 91401.26 185865.58, 91425.16 185867.55, 91426.43 185867.65, 91426.53 185867.66, 91445.1 185868.84, 91448.38 185869.05, 91461.31 185869.87, 91480.95 185874.53, 91481.34 185874.58, 91481.72 185874.65, 91752.61 185895.5, 91752.61 185895.5, 91752.61 185895.5, 91810.07 185899.92, 91909.04 185908.18, 91943.93 185912.97, 91972.6 185918.08, 92004.51 185925.38, 92258.43 185983.42, 92357.71 186006.42, 92357.71 186006.42, 92357.71 186006.42, 92374.37 186010.25, 92421.55 186021.1, 92421.86 186021.14, 92422.17 186021.2, 92422.35 186021.2, 92422.52 186021.22, 92422.84 186021.2, 92423.15 186021.2, 92423.32 186021.17, 92423.5 186021.15, 92423.8 186021.07, 92424.11 186021.01, 92427.86 186019.89, 92457.34 186026.23, 92459.28 186026.67, 92466.02 186028.2, 92495.27 186034.95, 92498.36 186035.67, 92499.35 186035.9, 92499.37 186035.9, 92511.84 186038.72, 92511.84 186038.72, 92511.84 186038.72, 92523.46 186041.34, 92526.54 186042.03, 92541.66 186045.45, 92541.66 186045.45, 92541.66 186045.45, 92547.92 186046.86, 92556.05 186048.77, 92559.37 186049.55, 92571 186052.29, 92571 186052.29, 92571 186052.29, 92584.83 186055.55, 92588.27 186056.36, 92596.55 186058.31, 92605.45 186060.44, 92608.89 186061.27, 92620.24 186063.99, 92620.24 186063.99, 92626.58 186065.51, 92628.66 186066.03, 92631.76 186066.81, 92645.2 186070.18, 92645.2 186070.18, 92645.2 186070.18, 92654.31 186072.47, 92654.46 186072.51, 92656.97 186073.19, 92667.94 186076.2, 92667.94 186076.2, 92676.75 186078.61, 92680.05 186079.51, 92691.2 186082.57, 92692.75 186083.02, 92692.75 186083.02, 92692.75 186083.02, 92702.87 186086, 92705.83 186086.87, 92722.8 186091.85, 92722.8 186091.85, 92728.16 186093.43, 92737.11 186096.16, 92740.29 186097.13, 92761.14 186103.5, 92788.43 186112.27, 92788.43 186112.27, 92788.43 186112.27, 92794.66 186114.28, 92794.72 186114.3, 92810.16 186119.04, 92810.16 186119.04, 92810.16 186119.04, 92827.65 186124.42, 92830.64 186125.34, 92833.32 186126.16, 92843.62 186129.39, 92843.62 186129.39, 92843.62 186129.39, 92854.85 186132.92, 92858.37 186134.02, 92872.41 186138.42, 92882.8 186141.79, 92885.63 186142.7, 92902.96 186148.31, 92902.96 186148.31, 92902.96 186148.31, 92916.16 186152.58, 92919.17 186153.56, 92919.2 186153.57, 92934.38 186158.39, 92934.38 186158.39, 92934.38 186158.39, 92946.57 186162.27, 92950.09 186163.39, 92958.63 186166.1, 92963.54 186167.67, 92963.54 186167.67, 92963.54 186167.67, 92974.45 186171.14, 92977.89 186172.24, 92991.81 186176.67, 92991.81 186176.67, 92991.81 186176.67, 93002.28 186180, 93003.05 186180.25, 93005.48 186181.04, 93016.39 186184.58, 93016.39 186184.58, 93025.72 186187.6, 93029.08 186188.69, 93042.75 186193.13, 93042.75 186193.13, 93042.75 186193.13, 93055.45 186197.25, 93058.64 186198.28, 93059.17 186198.45, 93059.2 186198.47, 93076.68 186204.02, 93076.68 186204.02, 93076.68 186204.02, 93090.96 186208.56, 93094.16 186209.58, 93116.72 186216.75, 93116.72 186216.75, 93116.72 186216.75, 93119.4 186217.6, 93125.7 186219.6, 93126.66 186219.8, 93127.64 186219.81, 93128.6 186219.63, 93129.51 186219.27, 93130.33 186218.74, 93131.03 186218.05, 93131.59 186217.24, 93131.98 186216.34, 93132.18 186215.38, 93132.19 186214.4, 93132.01 186213.44, 93131.65 186212.53, 93131.11 186211.71, 93130.43 186211.01, 93129.62 186210.45, 93128.72 186210.06, 93122.43 186208.07, 93119.75 186207.22, 93119.75 186207.22, 93119.75 186207.22, 93097.19 186200.05, 93093.99 186199.03, 93079.71 186194.49, 93079.71 186194.49, 93079.71 186194.49, 93062.24 186188.94, 93061.73 186188.77, 93058.53 186187.74, 93045.84 186183.62, 93045.84 186183.62, 93045.84 186183.62, 93032.17 186179.18, 93028.8 186178.09, 93019.48 186175.07, 93019.48 186175.07, 93019.48 186175.07, 93008.56 186171.52, 93006.12 186170.73, 93006.1 186170.72, 93005.32 186170.48, 92994.85 186167.14, 92994.85 186167.14, 92994.85 186167.14, 92980.92 186162.71, 92977.49 186161.61, 92966.57 186158.14, 92966.57 186158.14, 92966.57 186158.14, 92961.66 186156.58, 92953.12 186153.86, 92949.6 186152.74, 92937.41 186148.87, 92937.41 186148.87, 92937.41 186148.87, 92922.24 186144.04, 92919.24 186143.07, 92906.04 186138.8, 92906.04 186138.8, 92906.04 186138.8, 92888.71 186133.19, 92885.88 186132.27, 92875.47 186128.9, 92875.44 186128.9, 92875.42 186128.89, 92861.37 186124.48, 92857.84 186123.37, 92846.61 186119.85, 92846.61 186119.85, 92846.61 186119.85, 92836.3 186116.62, 92836.28 186116.61, 92833.58 186115.78, 92830.59 186114.86, 92813.1 186109.48, 92813.1 186109.48, 92813.1 186109.48, 92797.69 186104.75, 92791.49 186102.75, 92791.49 186102.75, 92791.49 186102.75, 92764.17 186093.97, 92764.1 186093.95, 92743.21 186087.57, 92740.03 186086.6, 92731.05 186083.86, 92731 186083.84, 92725.62 186082.26, 92725.62 186082.26, 92725.62 186082.26, 92708.64 186077.27, 92705.69 186076.4, 92695.57 186073.43, 92695.57 186073.43, 92695.57 186073.43, 92693.97 186072.96, 92693.88 186072.93, 92682.69 186069.87, 92679.39 186068.96, 92670.58 186066.55, 92670.58 186066.55, 92670.58 186066.55, 92659.61 186063.55, 92657.06 186062.85, 92656.96 186062.82, 92656.75 186062.77, 92656.74 186062.77, 92647.63 186060.48, 92647.63 186060.48, 92647.63 186060.48, 92634.2 186057.11, 92631.1 186056.34, 92628.99 186055.81, 92628.93 186055.79, 92622.57 186054.27, 92622.57 186054.27, 92622.57 186054.27, 92611.22 186051.54, 92607.79 186050.72, 92598.88 186048.58, 92598.87 186048.58, 92598.86 186048.58, 92590.56 186046.62, 92587.12 186045.81, 92573.3 186042.56, 92573.3 186042.56, 92573.3 186042.56, 92561.66 186039.82, 92558.34 186039.04, 92550.19 186037.12, 92550.14 186037.11, 92543.86 186035.69, 92543.86 186035.69, 92543.86 186035.69, 92528.74 186032.28, 92525.67 186031.58, 92514.04 186028.96, 92514.04 186028.96, 92514.04 186028.96, 92501.59 186026.15, 92500.61 186025.93, 92497.52 186025.21, 92468.26 186018.45, 92468.25 186018.45, 92468.24 186018.45, 92461.49 186016.92, 92459.53 186016.47, 92459.47 186016.46, 92428.7 186009.84, 92427.87 186009.74, 92427.03 186009.77, 92426.22 186009.94, 92422.5 186011.05, 92376.61 186000.5, 92359.96 185996.68, 92260.68 185973.68, 92260.67 185973.68, 92260.66 185973.67, 92006.74 185915.63, 91974.71 185908.3, 91974.47 185908.25, 91945.58 185903.11, 91945.38 185903.08, 91910.27 185898.25, 91910.14 185898.25, 91910 185898.22, 91810.88 185889.95, 91810.85 185889.95, 91753.37 185885.52, 91753.37 185885.52, 91753.37 185885.52, 91482.88 185864.71, 91463.21 185860.04, 91462.37 185859.92, 91449.02 185859.07, 91445.74 185858.86, 91427.21 185857.68, 91425.99 185857.58, 91425.99 185857.58, 91425.98 185857.58, 91402.05 185855.61, 91402 185855.6, 91396.89 185855.23, 91393.15 185854.96, 91393.13 185854.96, 91389.52 185854.71, 91373.01 185853.58, 91368.34 185853.08))

Screenshot from 2022-08-22 09-58-12

Thanks, I'll look into this! I checked in QGIS against the same base map and it looks fine there:

Screenshot 2022-08-22 at 22 44 27

A quick update on this. It looks like the provided data use a different transform for EPSG:31370 from the epsg.io default. https://epsg.io/31370 lists 4 possible transforms, and more are available in the database.

Here's a comparison of some of the available transformations as well as links to the app to show the resulting position shifts:

const proj = require("proj4");

const ll = [3.533646, 50.981898];

const transforms = [
    "+proj=lcc +lat_0=90 +lon_0=4.36748666666667 +lat_1=51.1666672333333 +lat_2=49.8333339 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-106.8686,52.2978,-103.7239,-0.3366,0.457,-1.8422,-1.2747 +units=m +no_defs +type=crs",
    "+proj=lcc +lat_0=90 +lon_0=4.36748666666667 +lat_1=51.1666672333333 +lat_2=49.8333339 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.059,53.322,-112.486,-0.419,0.83,-1.885,-1 +units=m +no_defs +type=crs",
    "+proj=lcc +lat_0=90 +lon_0=4.36748666666667 +lat_1=51.1666672333333 +lat_2=49.8333339 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-125.8,79.9,-100.5,0,0,0,0 +units=m +no_defs +type=crs"
];

for (tr of transforms) {
    transform = proj(tr);
    const xy = transform.forward(ll);
    console.log(xy);
    console.log(transform.inverse(xy));
    console.log("POINT(" + xy[0] + " " + xy[1] + ")");
}
[ 91414.67393509677, 186097.40546371788 ]
[ 3.5336459961458937, 50.98189800237258 ]
POINT(91414.67393509677 186097.40546371788)
[ 91413.81238005712, 186120.6889548935 ]
[ 3.533645997548646, 50.98189800299565 ]
POINT(91413.81238005712 186120.6889548935)
[ 91357.048349688, 186067.97347149067 ]
[ 3.53364599183403, 50.981898003474655 ]
POINT(91357.048349688 186067.97347149067)

I'll look into options for switching between transforms.

Related: maptiler/epsg.io#171