Closed giswqs closed 2 years ago
Yes, this is already implemented though not really exposed in the TileClient
. The server's endpoint to do this is /pixel/{left}/{right}
which you can see on my deployed server here: https://tileserver.banesullivan.com/swagger/
To use this locally with the TileClient
, do:
from localtileserver import TileClient
import requests
client = TileClient('/Users/bane/Desktop/TC_NG_SFBay_US_Geo.tif')
url = client.create_url('/pixel/0/0')
data = requests.get(url).json()
print(data)
output:
{'r': 99,
'g': 75,
'b': 48,
'a': 255,
'bands': {'1': 99.0, '2': 75.0, '3': 48.0},
'left': 0,
'top': 0,
'units': 'pixels'}
I will leave this open to implement a method on the TileClient
class to do this (as well as all the other endpoints)
The above is in pixel space. You can use the units parameter to use world coordinates.
I'll document this
That's great to know. I look forward to the implementation. Many thanks!
This functionality is changing a bit in #44
Is it possible to get pixel value by lat/lon for a local tile? Leafmap already has the functionality for retrieving pixel value by lat/lon for remote COGs using titiler endpoint or Planetary Computer endpoint. I would love to implement similar functionality for local tiles.
https://leafmap.org/common/#leafmap.common.cog_pixel_value https://github.com/giswqs/leafmap/blob/40973aed104376d04280d9215ce2d9e464681d3f/leafmap/common.py#L1187