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

Pixel to Meters ratio #28

Open
NPatch opened this issue Dec 18, 2020 · 0 comments
Open

Pixel to Meters ratio #28

NPatch opened this issue Dec 18, 2020 · 0 comments

Comments

@NPatch
Copy link

NPatch commented Dec 18, 2020

Hi, I got a heightmap, in which I understand, the URL lat/long to be for the center pixel. I'd like to sample the rest of the pixels given some projected coordinate(in the area covered by the map), but I'm not sure how that translates to pixel coordinates and back.

The map is exported using screen resolution(minus some pixels) and in my case, I get a 1920,920 map.

The only formula, from my attempts so far, that has kind of made sense was to query from the console the scene.view.size.meters and given the exported png dimensions, get the meter/pixel ratios per dimension, then find the top left pixel as a projected coordinate(subtracting from the central pixel's projected coordinates, scene.view.size.meters / 2.

Then given a projected coordinate in EPSG:3857(which I believe heighmapper uses), I convert that to pixels by subtracting the given projected_x from the top_left_x and and dividing with the (ViewMetersX/ViewWidth) ratio. For Y, I subtract the given projected.Y from the top_left_y since in pixel coordinates the positive direction for Y is down.

The result in pixels is correct for the X axis, but has error in Y. Any ideas on what I haven't factored in? Or perhaps misunderstood?

Thx!

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

1 participant