gee-community / geemap

A Python package for interactive geospatial analysis and visualization with Google Earth Engine.
https://geemap.org
MIT License
3.46k stars 1.09k forks source link

Output point locations from geemap.extract_values_to_points doesn’t match input #610

Closed nedhorning closed 3 years ago

nedhorning commented 3 years ago

I am using geemap.extract_values_to_points to extract pixel values under points from a Shapefile (EPSG: 4326) and outputting to a Shapefile. This is the raster image I’m using: ee.Image("projects/soilgrids-isric/clay_mean")

When I checked the results in QGIS the points in the output Shapefile did not align with the input Shapefile. They were displaced ~200m and therefore extracts data from a neighboring pixel. To fix that I specified scale = 10, projection = 'EPSG:4326'. This moved the output points so they were nearly identical, however, the values for the points correspond to the raster value of the original point location. In other words, the location is (more or less) correct the but data value is from the neighboring pixel.

I attached the Shapefile I'm using.

I’m running this on Ubuntu 20.04 with version 0.8.18 of geemap points_carbon_sequestration_gisel.zip

giswqs commented 3 years ago

Thanks for reporting! This bug has been fixed. Please update the package using geemap.update_package() and try again.

nedhorning commented 3 years ago

Thank you for the quick fix. I updated and tried without specifying the scale and projection: geemap.extract_values_to_points(points, clay, outShapefile) The point locations are perfect but it looks like it is still getting the value from the wrong pixel. I think this second part is a user problem since when I display the points in GEE they appear over different (neighbor) pixels compared to when I display them in QGIS.

giswqs commented 3 years ago

What basemap are you using in QGIS? Try using the same Google basemap in both QGIS and GEE. If the points appear to be at the same locations, then it might be the problem with the basemap you used.

https://nextgis.com/blog/quickmapservices/

bkavlak commented 3 years ago

Hey, I had the same problem and my solution was basically sampling points with the projection of the input image as here: image

After doing that, I was able to see them aligned with the input imagery (Sentinel-2 in my case) image

agrifallsoc commented 2 years ago

hi professor, I have a problem, when I convert the pixels to points, as follows: if I have some mistake in the code? thanks!

image