rinvex / countries

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips.
https://rinvex.com
MIT License
1.65k stars 206 forks source link

Wrong bounding box for China #182

Closed boris-glumpler closed 3 years ago

boris-glumpler commented 3 years ago

I've been using longlist.json to generate a list of countries and their bounding boxes from min_longitude, min_latitude, max_longitude and max_latitude. The resulting bbox (106.7,6.183333,117.816667,20.7) seems to be somewhere in the China Sea, tho, so close, but not really ;) I've finally found a bbox on humdata.org that works for my use-case: 74.167,18.163,135.078,53.5.

I can create a pull request if you're open to changing the affected coordinates? Cheers!

boris-glumpler commented 3 years ago

Obviously depends on your source, which might include disputed areas, remote islands, etc.

Omranic commented 2 years ago

If you still believe the included data in this package is not accurate, feel free to check the sources used for this package's data, and if you're still positive submit a PR with the reference and I'll be happy to consider it of course 👍

https://github.com/rinvex/countries#data-sources

jjjakobsen commented 2 years ago

It is now May 2022, and the China bbox is still completely wrong. Not even close to where it should be. And this is not related to politics or anything. It is simply wrong. Like placing the boundary box for the UK on top of Germany.

I'm not sure, which exact source was used for the China boundaries, but I assume it should have been https://raw.githubusercontent.com/mledoze/countries/master/data/chn.geo.json

That source inlcudes plenty of latitudes north of 20°, as does China itself - Beijing is at ~40°. But the China bbox here defines Chinas max Latitude at 20.7°

I wonder why this hasn't been fixed a long time ago. Maybe it is relevant only to very few people?

What bothers me the most is trust. Now I'm not sure if I can trust the data for the other 200+ countries and that is not good

boris-glumpler commented 2 years ago

I still use this package for some info, like languages, but switched to a full spatial database for anything coordinate-related by importing shapefiles from sites like https://www.naturalearthdata.com/

jjjakobsen commented 2 years ago

Thanks for a quick reply, Boris.

I'm sure you will agree that a very large part of China is located north of 20.7° latitude. So something must have gone wrong importing that data.

I could of course easily suggest a fix, but maybe it makes sense to understand what went wrong, since also other countries could have bad data.

What do you think?

boris-glumpler commented 2 years ago

Personally, unless your use case is really trivial, I'd push as much work as possible to the database. If you're working with bounding boxes you're probs dealing with GeoJson or some type of mapping application. Something like PostGIS is much better suited for that.

Having said that, I remember finding a fair amount of errors when checking the bounding boxes and those should really be fixed in the original source. You'd have to check how they get that data in that repo, tho.

Nowadays, I mainly use rinvex/countries to match 2-letter country codes to their translations and back again.

Omranic commented 2 years ago

@boris-glumpler @jjjakobsen

Thank you for the thoughtful discussion, and for the clarification.

However the boundary data was driven from sources that we tried to do as much due diligence as we can about it. That doesn't mean it's error-proof, given that this is not a trivial thing to do and validate all of these data for accuracy given that some boundaries may be disputed or not agreed upon.

I understand that you may have been looking for a more accurate geo data from this package, but that wasn't the main purpose and there's only limited resources we have to allocate in gathering all of these information and validating it all.

We tried to validate and verify the accuracy of what this package provides to the best of our ability, however I'm open to any PRs that may improve or fix any of the included information. If it's proven that most of the geo-data is not accurate, it may be a better idea to just drop off this feature for the time being until we've a better data source.

We have improved this package over the years by accepting generous contributions from the community, and this is highly appreciated and helps keeping this package as accurate and useful as possible; https://github.com/rinvex/countries/pulls?q=is%3Apr+is%3Amerged+

Happy to hear from you 🙂

boris-glumpler commented 2 years ago

Thanks for your response @Omranic.

So, I've just quickly pulled the bounding boxes from the Natural Earth data and if you look at China for example, then you get quite a different result:

// Natural Earth
max_latitude: "53.569444",
max_longitude: "134.772579",
min_latitude:  "15.775377",
min_longitude: "73.602256",

// Rinvex
max_latitude: "20.7",
max_longitude: "117.816667",
min_latitude: "6.183333",
min_longitude: "106.7",

I've exported the bounding boxes (min lng, min lat, max lng, max lat) for all sovereign countries excluding overseas territories and disputed areas as well in CSV format in case someone wants to compare these in more detail:

"code","bbox"
"AD","[1.406456, 42.428677, 1.765091, 42.649362]"
"AE","[51.569347, 22.620946, 56.383637, 26.074792]"
"AF","[60.486778, 29.386605, 74.892307, 38.473673]"
"AG","[-62.348260, 16.931970, -61.667592, 17.727688]"
"AI","[-63.428822, 18.169094, -62.925682, 18.601264]"
"AL","[19.272033, 39.637013, 21.036679, 42.654814]"
"AM","[43.436294, 38.863701, 46.602612, 41.290452]"
"AO","[11.669394, -18.031405, 24.061714, -4.391204]"
"AQ","[-180.000000, -90.000000, 180.000000, -60.516209]"
"AR","[-73.572740, -55.052016, -53.661552, -21.786938]"
"AS","[-171.086537, -14.532892, -168.160471, -11.051365]"
"AT","[9.521155, 46.378643, 17.148338, 49.009774]"
"AU","[112.919444, -54.750421, 159.106456, -9.240167]"
"AW","[-70.062408, 12.417670, -69.876820, 12.632148]"
"AX","[19.513194, 59.904486, 21.096690, 60.480780]"
"AZ","[44.774559, 38.392645, 50.625743, 41.890442]"
"BA","[15.716074, 42.559212, 19.618885, 45.284524]"
"BB","[-59.654205, 13.051174, -59.426910, 13.344550]"
"BD","[88.021790, 20.738715, 92.642851, 26.623544]"
"BE","[2.521800, 49.495223, 6.374525, 51.496238]"
"BF","[-5.522578, 9.391883, 2.390169, 15.079908]"
"BG","[22.345023, 41.238104, 28.603526, 44.228435]"
"BH","[50.380530, 25.579891, 50.819875, 26.287439]"
"BI","[28.986892, -4.463344, 30.833962, -2.303062]"
"BJ","[0.759881, 6.213894, 3.837419, 12.399244]"
"BL","[-62.867340, 17.881985, -62.791656, 17.929145]"
"BM","[-64.885994, 32.248077, -64.647631, 32.388658]"
"BN","[113.998790, 4.016681, 115.360741, 5.057196]"
"BO","[-69.666492, -22.897258, -57.465661, -9.679821]"
"BR","[-74.018475, -33.742280, -28.877065, 5.267225]"
"BS","[-79.594350, 20.912399, -72.746165, 26.928412]"
"BT","[88.730067, 26.696149, 92.088776, 28.358399]"
"BW","[19.978346, -26.891794, 29.350074, -17.781808]"
"BY","[23.165645, 51.235168, 32.719532, 56.156806]"
"BZ","[-89.236512, 15.879652, -87.783070, 18.490759]"
"CA","[-141.005564, 41.669086, -52.616607, 83.116523]"
"CD","[12.210541, -13.458351, 31.280447, 5.375280]"
"CF","[14.387266, 2.236454, 27.441301, 11.000828]"
"CG","[11.114016, -5.019631, 18.642407, 3.708276]"
"CH","[5.954809, 45.820718, 10.466627, 47.801166]"
"CI","[-8.618720, 4.344062, -2.506328, 10.726478]"
"CK","[-165.824534, -21.938897, -157.312815, -8.946710]"
"CL","[-109.453725, -55.918504, -66.420806, -17.506588]"
"CM","[8.505056, 1.654551, 16.207723, 13.081141]"
"CN","[73.602256, 15.775377, 134.772579, 53.569444]"
"CO","[-81.723704, -4.236484, -66.875061, 13.578355]"
"CR","[-87.117665, 5.515082, -82.562837, 11.209937]"
"CU","[-84.949615, 19.827826, -74.132883, 23.265570]"
"CV","[-25.360422, 14.803941, -22.666575, 17.196601]"
"CW","[-69.171742, 12.041327, -68.739735, 12.391506]"
"CY","[32.271739, 34.625019, 34.099132, 35.187082]"
"CZ","[12.076141, 48.557916, 18.837434, 51.040012]"
"DE","[5.852490, 47.271121, 15.022059, 55.065334]"
"DJ","[41.749110, 10.929825, 43.418712, 12.707913]"
"DK","[8.094005, 54.568590, 15.151378, 57.751166]"
"DM","[-61.488922, 15.201809, -61.249257, 15.633857]"
"DO","[-72.009838, 17.545559, -68.328603, 19.937690]"
"DZ","[-8.682385, 18.975561, 11.968861, 37.093940]"
"EC","[-92.011586, -5.011373, -75.227264, 1.664374]"
"EE","[21.832367, 57.515819, 28.186475, 59.670885]"
"EG","[24.688343, 21.994369, 36.899181, 31.656480]"
"EH","[-17.104644, 20.766913, -8.680809, 27.661465]"
"ER","[36.423647, 12.360022, 43.123871, 18.004828]"
"ES","[-18.167226, 27.642239, 4.337087, 43.793443]"
"ET","[32.989800, 3.403333, 47.979169, 14.879532]"
"FI","[20.623165, 59.811225, 31.569525, 70.075310]"
"FJ","[-180.000000, -21.711114, 180.000000, -12.475274]"
"FK","[-61.318186, -52.406523, -57.734283, -51.027765]"
"FM","[138.063813, 0.918158, 163.046560, 9.775580]"
"FO","[-7.644154, 61.394110, -6.275787, 62.398912]"
"GA","[8.695567, -3.936856, 14.498991, 2.322495]"
"GB","[-13.691314, 49.909613, 1.771169, 60.847886]"
"GD","[-61.790517, 12.002834, -61.421620, 12.529731]"
"GE","[39.985976, 41.044111, 46.694803, 43.575843]"
"GG","[-2.673451, 49.411566, -2.170318, 49.731391]"
"GH","[-3.262509, 4.737128, 1.187968, 11.162937]"
"GI","[-5.358387, 36.110500, -5.338773, 36.141120]"
"GL","[-73.057240, 59.792629, -11.376820, 83.634101]"
"GM","[-16.829701, 13.065009, -13.818713, 13.819984]"
"GN","[-15.081125, 7.190208, -7.662447, 12.673388]"
"GQ","[5.611990, -1.475681, 11.336341, 3.772406]"
"GR","[19.626475, 34.815009, 28.239757, 41.750476]"
"GS","[-38.087026, -59.472752, -26.239329, -53.972426]"
"GT","[-92.246257, 13.731404, -88.220937, 17.816020]"
"GU","[144.624197, 13.241034, 144.952159, 13.654120]"
"GW","[-16.728437, 10.927639, -13.660712, 12.679434]"
"GY","[-61.396713, 1.185820, -56.481819, 8.558010]"
"HK","[113.837332, 22.177069, 114.401296, 22.563946]"
"HM","[73.236013, -53.192560, 73.812185, -52.961602]"
"HN","[-89.363791, 12.979777, -83.130444, 17.418647]"
"HR","[13.501475, 42.416327, 19.407838, 46.546979]"
"HT","[-74.489166, 18.025946, -71.639111, 20.089789]"
"HU","[16.094035, 45.741343, 22.877601, 48.569233]"
"ID","[95.012706, -10.922621, 140.977627, 5.910102]"
"IE","[-10.478179, 51.445705, -5.993520, 55.386379]"
"IL","[34.248351, 29.489691, 35.888073, 33.406722]"
"IM","[-4.790151, 54.056952, -4.311920, 54.419013]"
"IN","[68.143403, 6.745551, 97.362253, 35.495406]"
"IO","[71.260997, -7.432224, 72.494640, -5.226983]"
"IQ","[38.774511, 29.063137, 48.559255, 37.375498]"
"IR","[44.014863, 25.059408, 63.319628, 39.771527]"
"IS","[-24.539906, 63.396715, -13.502919, 66.564154]"
"IT","[6.602728, 35.489244, 18.517426, 47.085215]"
"JE","[-2.242014, 49.171332, -2.008290, 49.267035]"
"JM","[-78.374664, 17.703192, -76.187978, 18.525092]"
"JO","[34.949385, 29.189951, 39.291999, 33.371685]"
"JP","[122.938162, 24.212104, 153.985606, 45.520413]"
"KE","[33.890468, -4.677504, 41.885019, 5.030376]"
"KG","[69.226296, 39.189237, 80.257561, 43.261702]"
"KH","[102.313424, 10.415774, 107.610516, 14.704582]"
"KI","[-174.543406, -11.461114, 176.850922, 4.723090]"
"KM","[43.213227, -12.380304, 44.529063, -11.361261]"
"KN","[-62.861073, 17.100531, -62.536773, 17.415839]"
"KP","[124.211316, 37.675605, 130.699962, 43.010270]"
"KR","[124.613617, 33.197577, 131.862522, 38.624335]"
"KW","[46.532436, 28.533505, 48.432781, 30.098216]"
"KY","[-81.416542, 19.263864, -79.726643, 19.757631]"
"KZ","[46.478279, 40.584656, 87.323796, 55.434550]"
"LA","[100.097073, 13.915457, 107.664363, 22.496044]"
"LB","[35.099620, 33.055580, 36.604101, 34.687548]"
"LC","[-61.078521, 13.714667, -60.882965, 14.111884]"
"LI","[9.475886, 47.052400, 9.615723, 47.262801]"
"LK","[79.655772, 5.923733, 81.890310, 9.829576]"
"LR","[-11.476186, 4.347235, -7.384118, 8.565396]"
"LS","[27.002155, -30.658799, 29.435908, -28.570761]"
"LT","[20.924569, 53.886841, 26.800720, 56.442602]"
"LU","[5.714927, 49.441324, 6.502579, 50.174975]"
"LV","[20.968598, 55.666991, 28.217275, 58.075138]"
"LY","[9.286544, 19.496124, 25.156261, 33.181225]"
"MA","[-17.013743, 21.419971, -1.031999, 35.926519]"
"MC","[7.365750, 43.717969, 7.437454, 43.763506]"
"MD","[26.617889, 45.461774, 30.131576, 48.486034]"
"ME","[18.433531, 41.852362, 20.355171, 43.547886]"
"MF","[-63.146840, 18.033391, -63.010732, 18.122138]"
"MG","[43.222911, -25.598565, 50.503917, -11.943617]"
"MH","[165.282237, 4.573798, 172.029796, 14.610500]"
"MK","[20.444157, 40.849394, 23.009582, 42.370335]"
"ML","[-12.264130, 10.140054, 4.235638, 24.995065]"
"MM","[92.174973, 9.790717, 101.173855, 28.538466]"
"MN","[87.735709, 41.586145, 119.907027, 52.129584]"
"MO","[113.519867, 22.105373, 113.587494, 22.220771]"
"MP","[144.902110, 14.110663, 145.868907, 20.555406]"
"MR","[-17.081175, 14.734399, -4.821613, 27.285416]"
"MS","[-62.230133, 16.675360, -62.140533, 16.819322]"
"MT","[14.183604, 35.801215, 14.567149, 36.075588]"
"MU","[56.524181, -20.517348, 63.493907, -10.323907]"
"MV","[72.684825, -0.688572, 73.753184, 7.107245]"
"MW","[32.663308, -17.135335, 35.904299, -9.381235]"
"MX","[-118.368804, 14.546279, -86.700592, 32.712836]"
"MY","[99.645228, 0.851370, 119.278087, 7.355780]"
"MZ","[30.213845, -26.860272, 40.847992, -10.469008]"
"NA","[11.717621, -28.959368, 25.259781, -16.951057]"
"NC","[163.615733, -22.670668, 171.343765, -19.623712]"
"NE","[0.152941, 11.695773, 15.970322, 23.517351]"
"NF","[167.912120, -29.080011, 167.996349, -28.997491]"
"NG","[2.671082, 4.272162, 14.669936, 13.880291]"
"NI","[-87.685821, 10.713482, -82.725697, 15.030970]"
"NL","[-68.417388, 12.022040, 7.198506, 53.558092]"
"NP","[80.030288, 26.343768, 88.169067, 30.416904]"
"NR","[166.906993, -0.551853, 166.958263, -0.490411]"
"NU","[-169.950429, -19.142755, -169.782908, -18.964044]"
"NZ","[-177.957997, -52.600313, 178.843923, -8.543227]"
"OM","[51.978615, 16.642401, 59.844574, 26.385972]"
"PA","[-83.053246, 7.205715, -77.163270, 9.629292]"
"PE","[-81.337558, -18.337746, -68.684252, -0.029093]"
"PF","[-154.536977, -27.641209, -134.942983, -7.950128]"
"PG","[140.849211, -11.636326, 155.967540, -1.346368]"
"PH","[116.954926, 4.655707, 126.617686, 21.122382]"
"PK","[60.844379, 23.694525, 77.048971, 37.054484]"
"PL","[14.123923, 48.994013, 24.143156, 54.838324]"
"PM","[-56.396596, 46.752753, -56.144765, 47.141262]"
"PN","[-130.753082, -25.077081, -124.778066, -23.924412]"
"PR","[-67.937815, 17.922919, -65.244618, 18.522773]"
"PS","[34.200269, 31.211449, 35.572536, 32.542640]"
"PT","[-31.284901, 30.029242, -6.205947, 42.153630]"
"PW","[131.131114, 2.949042, 134.727343, 8.096618]"
"PY","[-62.650357, -27.586842, -54.245289, -19.286729]"
"QA","[50.750987, 24.559872, 51.616547, 26.160102]"
"RO","[20.242826, 43.650050, 29.699555, 48.274832]"
"RS","[18.844978, 42.234945, 22.984571, 46.173875]"
"RU","[-180.000000, 41.192681, 180.000000, 81.858710]"
"RW","[28.857236, -2.826855, 30.887809, -1.058694]"
"SA","[34.572765, 16.370958, 55.637565, 32.121348]"
"SB","[155.507986, -12.290623, 168.825857, -6.599867]"
"SC","[46.207367, -9.755548, 56.287446, -3.791111]"
"SD","[21.809449, 8.681642, 38.603852, 22.226965]"
"SE","[11.108165, 55.342678, 24.163414, 69.036356]"
"SG","[103.640391, 1.264309, 104.003429, 1.448635]"
"SH","[-14.417714, -40.397882, -5.650380, -7.877862]"
"SI","[13.365261, 45.423637, 16.515302, 46.863962]"
"SK","[16.844480, 47.750006, 22.539637, 49.601780]"
"SL","[-13.301096, 6.919420, -10.282236, 9.996006]"
"SM","[12.385629, 43.892056, 12.492392, 43.982567]"
"SN","[-17.536041, 12.305607, -11.377776, 16.691385]"
"SO","[40.965385, -1.696303, 51.417038, 11.989119]"
"SR","[-58.067691, 1.833507, -53.986357, 6.011574]"
"SS","[24.121556, 3.490202, 35.920835, 12.216155]"
"ST","[6.461681, 0.024115, 7.462738, 1.699774]"
"SV","[-90.114779, 13.158637, -87.693194, 14.445373]"
"SX","[-63.118886, 18.019110, -63.017569, 18.062120]"
"SY","[35.723399, 32.313042, 42.377186, 37.324906]"
"SZ","[30.782906, -27.316264, 32.117398, -25.735999]"
"TC","[-72.481313, 21.290107, -71.128896, 21.959215]"
"TD","[13.449184, 7.455567, 23.984406, 23.444720]"
"TF","[39.728282, -49.721612, 77.585216, -11.550632]"
"TG","[-0.166109, 6.100491, 1.782351, 11.134980]"
"TH","[97.351401, 5.629890, 105.650998, 20.445006]"
"TJ","[67.342690, 36.678641, 75.164125, 41.039977]"
"TL","[124.030040, -9.501228, 127.313243, -8.135024]"
"TM","[52.437671, 35.140647, 66.645782, 42.791188]"
"TN","[7.479832, 30.228905, 11.564131, 37.345201]"
"TO","[-176.219309, -22.338800, -173.914255, -15.559503]"
"TR","[25.663259, 35.819779, 44.806993, 42.098782]"
"TT","[-61.928700, 10.042060, -60.522084, 11.351060]"
"TV","[176.125255, -9.420668, 179.906749, -5.677504]"
"TW","[118.279552, 21.904608, 122.005382, 25.287421]"
"TZ","[29.321032, -11.731272, 40.449392, -0.985830]"
"UA","[22.132840, 45.213568, 40.159543, 52.368949]"
"UG","[29.548460, -1.475206, 35.006473, 4.219692]"
"UM","[-177.389597, -0.388767, 166.652354, 28.215318]"
"US","[-179.143503, 18.906117, 179.780935, 71.412502]"
"UY","[-58.439361, -34.973403, -53.110836, -30.096870]"
"UZ","[55.975839, 37.185147, 73.148641, 45.558719]"
"VA","[12.452714, 41.902752, 12.454035, 41.903915]"
"VC","[-61.459828, 12.585150, -61.123931, 13.380764]"
"VE","[-73.391149, 0.649315, -59.815595, 15.702948]"
"VG","[-64.773997, 18.334662, -64.270741, 18.746243]"
"VI","[-65.041493, 17.682766, -64.559397, 18.386599]"
"VN","[102.118655, 8.565579, 109.472423, 23.366275]"
"VU","[166.520518, -20.253106, 169.898936, -13.064874]"
"WF","[-178.185740, -14.319431, -176.125600, -13.208917]"
"WS","[-172.782582, -14.052830, -171.437693, -13.462823]"
"XK","[20.024751, 41.844010, 21.772758, 43.263071]"
"YE","[42.545746, 12.111444, 54.540294, 18.995638]"
"ZA","[16.469981, -46.965753, 37.977794, -22.126452]"
"ZM","[21.979878, -18.069232, 33.674203, -8.194124]"
"ZW","[25.219370, -22.397340, 33.042768, -15.614808]"
Omranic commented 2 years ago

Thanks, I'd be happy to consider any PRs fixing these issues 👍