Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge_divide_trees: features in KML and TXT output #26

Open
anbj opened this issue Jan 8, 2024 · 12 comments
Open

merge_divide_trees: features in KML and TXT output #26

anbj opened this issue Jan 8, 2024 · 12 comments

Comments

@anbj
Copy link
Contributor

anbj commented Jan 8, 2024

The contents of merged.txt is identical, but the contents of merged-divide_tree.kml differs when running merge_divide_trees with or without -f. Is this expected? Note I'm only checking Peaks in the KML-file.

$ merge_divide_trees merged prominence-72x00-002x00-divide_tree_pruned_0.dvt
$ ogrinfo -so merged-divide_tree.kml Peaks
INFO: Open of `merged-divide_tree.kml'
      using driver `LIBKML' successful.

Layer name: Peaks
Geometry: Unknown (any)
Feature Count: 145       <--------------
[...]

$ wc merged.txt 
  66   66 3036 merged.txt

Now lets run again with -f:

$ merge_divide_trees -f merged prominence-72x00-002x00-divide_tree_pruned_0.dvt
$ ogrinfo -so merged-divide_tree.kml Peaks
INFO: Open of `merged-divide_tree.kml'
      using driver `LIBKML' successful.

Layer name: Peaks
Geometry: Unknown (any)
Feature Count: 70       <--------------
[...]
$ wc merged.txt 
  66   66 3036 merged.txt
@akirmse
Copy link
Owner

akirmse commented Jan 8, 2024

Yes, this is expected. -f deletes the "runoffs", which are intermediate entities that are needed if the output is to be merged further. You can read more about runoffs at https://www.andrewkirmse.com/prominence.

The KML output is mostly for debugging purposes. Maybe I should default to not generating it.

@anbj
Copy link
Contributor Author

anbj commented Jan 8, 2024

Thank you, and sorry for posing questions that I should be able to figure out myself.
I've read your posts about this, I just need to grasp it.

I've been able to create a routine that takes (x,y,z), resamples and processes the data into a grid that prominence and WinProm can use. Very exciting.

Oh, and one more thing; I just processed a tile, and was very surprised that the highest point in my tile, was not included in the final data set. Need to look at it some more, but do you have any idea if this would be an issue if the input grid contains only negative numbers? This is bathymetry, so all z-values < 0. Since Mt. Everest is the highwat point on the land masses, the prominence is by definition, it's height (I think..). But how do you do this when < 0. What's the datum?!

@akirmse
Copy link
Owner

akirmse commented Jan 8, 2024

Hm, yes, that's true, there's not really a well-defined prominence value for the highest point < 0. For Everest, using the elevation matches intuition as the high point of a land mass, but I don't know what the right answer is for bathymetry.

@anbj
Copy link
Contributor Author

anbj commented Jan 26, 2024

  • Ref. my post above, I'm a bit puzzled.

  • Without introducing my own confused musings on this, here's a note.

  • I have generated an 'SRTM pseudo tile' based on data from various sources. All is bathymetry, so z < 0. The region is 2E-3E, 72-73N.

  • Since the highest peak, based on eyeballing, is missing, I thought it may have something to do with the negative z's.

  • I took my original grid and added 4000 to the z-value. 4000 was arbitrarily chosen, just to get all z > 0.

  • Here's screenshot of a run with the original grid (z < 0). From the kml-file:
    org-kml

  • And the resulting txt-file:
    org-txt

  • And here's a screenshot of a run with the shifted grid (z > 0). From the kml file:
    shifted-kml

  • And the resulting txt-file:
    shifted-txt

  • If you want to do your own run, I'm attaching the files.
    files.zip

    • N72E002-original.hgt - original file, z < 0.
    • N72E002-shifted.hgt - shifted (+4000) file, z > 0.

@akirmse
Copy link
Owner

akirmse commented Jan 26, 2024

I ran the following two commands on each input tile:

\mountains\code\release\prominence.exe -f SRTM 72 73 2 3 
\mountains\code\release\merge_divide_trees -f output prominence-72x00-002x00-divide_tree_pruned_100.dvt

What I found is similar to what you're seeing. The shifted version has two additional output points. One is the dataset high point, which is expected to be missing in the output for the original tile, because as we discussed, it's not clear what the prominence of that point is when the data is all negative. But the other looks like it may be a bug. I'm investigating.

(Note that since we didn't specify a min prominence, the default value of 100 was used. Also, I ran merge_divide_trees with the -f flag, which removed points around the boundary that don't have sufficient prominence within the tile, but which might if the tile were merged with neighbors. I did that just to reduce the number of points I had to look at.)

@anbj
Copy link
Contributor Author

anbj commented Jan 26, 2024

Thanks!

And sorry for not including the commands I ran. I think it was the default value for min. prominence (i.e. 100).

@akirmse
Copy link
Owner

akirmse commented Jan 26, 2024

I did some careful debugging and did see a tiny difference in one calculation that I couldn't explain. I did a diff of the two rasters in QGIS and found that most corresponding pixels have a difference of 4000, but a non-trivial number (a few hundred) have a difference of 4001. That might or might not explain the prominence difference, but it does make debugging extremely difficult. Is it possible this is due to floating point discrepancies in the shift you applied?

@akirmse
Copy link
Owner

akirmse commented Jan 26, 2024

It's also possible that QGIS is producing false positives due to floating point rounding.. just wanted to be sure you know that the two rasters are exactly 4000 apart everywhere.

@anbj
Copy link
Contributor Author

anbj commented Jan 29, 2024

Interesting. I'm using GMT's (https://www.generic-mapping-tools.org/) grdmath to shift the grid, and I don't think this should cause/introduce any floating point discrepancies, but who knows. I'll do some investigation.

Thanks for your interest in this!

@anbj
Copy link
Contributor Author

anbj commented May 16, 2024

You want me to close this?

@akirmse
Copy link
Owner

akirmse commented May 16, 2024

Up to you.. I haven't looked at it again. I'd need to know more about how the shift of 4000 was done before investigating further, in case that's what introduced the discrepancy.

@anbj
Copy link
Contributor Author

anbj commented May 16, 2024

Thanks. I'll keep it open then. I hope to have more time to investigate at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants