sahrk / DGGRID

A command-line application that generates and manipulates icosahedral discrete global grids.
GNU Affero General Public License v3.0
78 stars 26 forks source link

Fatal error "coordinate out of range" for TRANSFORM_POINTS operation on resolution 9 and 11 for ISEA7H #75

Closed tik65536 closed 5 months ago

tik65536 commented 6 months ago

Hi there,

I am new to geoinformatics and recently I was involved in a project using dggrid for coordinate conversion ( lon , lat to cell id). I have encountered the following error when I try to convert the extent [ 1.71958561 46.28503214 39.73779407, 71.92515178] : FATAL ERROR: DgQ2DDtoIConverter::convertTypedAddress(): coordinate out of range: (3419, 16808)

Here are the detial on the conversion flow :

  1. I have a raster layer for the extent mentioned above with pixel (2621 x 1407)
  2. Then, I calculate the (lon,lat) pair for each pixel for the input file of dggrid
  3. After that, I specify the dggrid operation to TRANSFORM_POINTS with dggrid type to ISEA7H with resolution 9
  4. Then it failed with the above error after converting 337 points

Comparing the input and output file, the point that causes the error is identified : 11.253953633882894 70.88136158886851 0 "POINT (11.253953633882894 70.88136158886851)"

The wired things is that, the conversion works for resolution 8, 10 , but fails for 9 and 11 which look like it work fines with even resolution but not for the odd.

May I ask if there are any hits or suggestions on how to troubleshoot the above case ?

I have attached the config file and the output file for reference, the input_file is too large to attach in the issue. Please let me know if further information is needed.

Thanks in advance, Tik

seqnums_1062352b-8647-45e7-919e-9839bf9c9885.txt metafile_cee8bdd3-88f5-4c3e-8a8a-8adcbbd48d93.txt

sahrk commented 5 months ago

Thanks @tik65536 for finding this. There was a problem binning some points that are very close to certain icosahedron edges into odd aperture 7 resolutions. It does not look like the bug affected any other operations.

A fix for this bug is now in the master branch. Please let me know if you encounter the problem again.

tik65536 commented 5 months ago

Hi Kevin,

Thanks for your effort for helping on the issue. I have pulled the latest change from github and try with res 7 and 9, but the problem still exists; however, in comparison to the previous one, it does convert much more points before it fails with coordinate out of range error.

Please let me know if you need any additional info for trouble shooting.

Thanks, Tik

sahrk commented 5 months ago

Can you give me a handful of longitude/latitude points that still fail?

tik65536 commented 5 months ago

Thx ~ According to the output file , it should fail at the following coord , the res is 9 . 11.249728095525505 64.93008402062712 0 "POINT (11.249728095525505 64.93008402062712)"

(additional points that fail with out of coord)

17.552368275507753 52.87256173618977 0 "POINT (17.552368275507753 52.87256173618977)" 11.248800470494485 62.566404740531326 0 "POINT (11.248800470494485 62.566404740531326)" 7.224012235377092 55.03814947212351 0 "POINT (7.224012235377092 55.03814947212351)" 11.249359492857108 68.57580046264071 0 "POINT (11.249359492857108 68.57580046264071)" 11.249915497612301 66.77385225556525 0 "POINT (11.249915497612301 66.77385225556525)" 9.629615930623713 57.054606355312366 0 "POINT (9.629615930623713 57.054606355312366)" 21.37867730654715 48.554360613802025 0 "POINT (21.37867730654715 48.554360613802025)" 19.62509029372895 50.649997199035155 0 "POINT (19.62509029372895 50.649997199035155)" 6.500611724172467 58.98881760805852 0 "POINT (6.500611724172467 58.98881760805852)" 11.249517821662737 70.80866647719836 0 "POINT (11.249517821662737 70.80866647719836)" 11.249517821662737 70.80866647719836 0 "POINT (11.249517821662737 70.80866647719836)" 27.157549477137284 59.90703409003816 0 "POINT (27.157549477137284 59.90703409003816)"

sahrk commented 5 months ago

That should be plenty, thanks! I'll have a look asap.

sahrk commented 5 months ago

@tik65536 I'm pretty sure I now have a version that handles all cases, including all the test points you posted. I want to do a little more testing before I merge the fix into the master branch, just to make sure it doesn't break anything on other apertures. But if you want to give it a try the fix is in branch z7.

tik65536 commented 5 months ago

@sahrk , Thanks for your effort and helps , I had tried with z7 branch and it's working fine ~

sahrk commented 5 months ago

@tik65536 the fixes are now in master, along with a couple of fixes to other bugs.