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

Annotate RasterLayer queryset with pixel value #53

Open
vtoupet opened this issue Sep 25, 2020 · 1 comment
Open

Annotate RasterLayer queryset with pixel value #53

vtoupet opened this issue Sep 25, 2020 · 1 comment

Comments

@vtoupet
Copy link

vtoupet commented Sep 25, 2020

Hi,

is there a way to annotate a RasterLayer queryset with pixel value for given coordinates? If not, how would you do to retrieve pixel value for a bunch of RasterLayer in an effective manner?

Thanks.

@yellowcap
Copy link
Member

The raster queryset does not support this kind of annotation. To retrieve the pixel value, django-raster has an url endpoint that you can use, see https://django-raster.readthedocs.io/en/stable/algebra.html#pixel-value-lookup.

But I suppose you want to to this server side. For this case the quickest way is probably to identify the RasterTile that intersects with your point, get the tile, and use an internal utility function from django-raster to get the correct pixel.

To get you started, here is the part of the view that selects the RasterTile index https://github.com/geodesign/django-raster/blob/master/raster/views.py#L141 , and here is the utility function to get a pixel value based on a GDALRaster object https://github.com/geodesign/django-raster/blob/master/raster/utils.py#L132

Hope this helps.

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