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

Shift in dem.value_at_coord or dem.show #355

Closed
LucBeraud opened this issue Mar 2, 2023 · 1 comment · Fixed by #351
Closed

Shift in dem.value_at_coord or dem.show #355

LucBeraud opened this issue Mar 2, 2023 · 1 comment · Fixed by #351
Labels
bug Something isn't working

Comments

@LucBeraud
Copy link

LucBeraud commented Mar 2, 2023

Describe the bug
There seems to be a diagonal ~ half-pixel shift between the DEM.show() displays and the DEM.value_at_coord() output.

To Reproduce
import xdem
img = xdem.DEM(gu.examples.get_path('everest_landsat_b4'))
target_x, target_y = 486811, 3097050 # example of coordinate
fig,ax=plt.subplots(1,1)
img.show(vmin=50, vmax=200, ax=ax)
ax.set_xlim(target_x-60,target_x+60); ax.set_ylim(target_y-60,target_y+60) # zoom on the area
ax.scatter(target_x, target_y,c='r') # plot the desired coordinate on the image plot
ax.set_title('at ({}, {}), dem.value_at_coords={}'.format(target_x, target_y, np.round(img.value_at_coords(target_x, target_y), 2))) # prints as figure title the value returned by value_at_coords()
ax.plot([486805, 486805, 486805+30, 486805+30, 486805],[3097056,3097056-30, 3097056-30, 3097056, 3097056]) # if coord falls in this blue polygon
ax.plot([486820, 486820, 486820+30, 486820+30, 486820],[3097040,3097040-30, 3097040-30, 3097040, 3097040]) # it returns the value of this orange one

Expected behavior
The value_at_coord() value does not return same value as the plot most of the time, I expect that the value_at_coords() (169 in the example, value of the orange box pixel) matches the show() pixels (131 in the example, under the red point).

System (please complete the following information):

  • OS: Ubuntu 22
  • Environment : xdem (0.0.7, 823fff2 commit), geoutils (0.0.10)
    Capture d’écran du 2023-03-02 15-15-19
@LucBeraud LucBeraud added the bug Something isn't working label Mar 2, 2023
@rhugonnet
Copy link
Contributor

Thanks for the reproducible example, helped a lot!

Found the guilty line: 3267726

Turns out our test_value_at_coords function had the same value for neighbouring pixels, and so it went unnoticed. This is fixed as well: 147363e

Will be closed when #351 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants