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

suggestion: parser returns absolute coordinates of each height #1

Open
Vichoko opened this issue Nov 12, 2018 · 4 comments
Open

suggestion: parser returns absolute coordinates of each height #1

Vichoko opened this issue Nov 12, 2018 · 4 comments

Comments

@Vichoko
Copy link

Vichoko commented Nov 12, 2018

It's kinda tricky to do the mapping of row / columns to coordinates.
It could be a useful feature.

@jbouzekri
Copy link
Member

@Vichoko : Sorry I don't understand what you mean. Can you provide an example or give more detail ?

@Vichoko
Copy link
Author

Vichoko commented Nov 12, 2018

I were confused by the square corners, as i imagined the hgt file contained punctual heights not a tiling of the surface.

Now i see that the iterator include the square corners coordinates, and with that i can get the coordinates of each cell by getting the mean of the corners or subtracting 1/2400 to the top-right corner.

(i'm trying to export the hgt files to a more flexible data structure)

@Vichoko Vichoko closed this as completed Nov 12, 2018
@Vichoko Vichoko reopened this Nov 12, 2018
@Vichoko
Copy link
Author

Vichoko commented Nov 12, 2018

I think for indexing it is useful and lighter to retrieve the coordinate of the center of the square instead of the corners (1 value versus 4 values)
In the case of this library, getting the center is a matter of substracting 1/2400 to the top-right corner of each cell.

@jbouzekri
Copy link
Member

Indeed, you are right, it would be more like only : lat of the center, lng of the center and another global one for the whole file which is the size of a square.

But the intended use case of this library was with PostGIS and its raster format which needs the 4 coordinates of a square. And with the rounding issue (it took me a few hours to find a solution without errors), I did not want to have somebody else with the same problem.

If needed, we could imagine something like this:

>>> with HgtParser('/tmp/N00E010.hgt') as parser:
...    for elev_value in parser.get_value_iterator(square_mode=False):
...        # each value is a tuple (zero based line number, zero based column number, zero based index, (center coordinates, square width), elevation value)
...        print(elev_value)
...        break
...
(0, 0, 0, ((0.9995833333333334, 9.999583333333334), 0.83333333333334), 57)

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