-
Notifications
You must be signed in to change notification settings - Fork 29
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
Passing rasterio.Env context to tile server #182
Comments
The If you set these AWS env params in the environment of the host, it should work without issue. I'm still trying to massively refactor localtileserver and will try to account for this usage scenario better |
This is definitely doable, but I'm trying to come up with the best/safest approach here. One thing I just realized is the import rasterio
from rasterio.session import AWSSession
from fastapi import FastAPI
from server_thread import ServerThread
import requests
import os
import json
app = FastAPI()
@app.get("/")
def root():
# this is where we would do all our tileserving magic and need access to the Env
return json.loads(os.environ["LOCALTILESERVER_ENV"])
aws_session = AWSSession(
aws_unsigned=True
)
with rasterio.Env(session=aws_session):
os.environ["LOCALTILESERVER_ENV"] = json.dumps(rasterio.env.getenv())
server = ServerThread(app)
response = requests.get(f"http://{server.host}:{server.port}/")
respons.json() But this doesn't feel right to me... and I'm pretty sure would conflict if multiple |
Just came accross the rio-tiler-pds package. Seems relevant to the issue here. |
developmentseed/titiler#186 might be of interest |
@banesullivan @vincentsarago Thank you both for the pointers. I was able to make it work by setting the environment variables. import os
from ipyleaflet import Map
from localtileserver import TileClient, get_leaflet_tile_layer
os.environ["AWS_ACCESS_KEY_ID"] = "YOUR-KEY"
os.environ["AWS_SECRET_ACCESS_KEY"] = "YOUR-TOKEN"
os.environ["AWS_REQUEST_PAYER"] = "requester"
src = 's3://naip-analytic/tn/2021/60cm/rgbir_cog/34084/m_3408401_ne_16_060_20210404.tif'
client = TileClient(src)
t = get_leaflet_tile_layer(client, indexes=[1, 2, 3])
m = Map(center=client.center(), zoom=client.default_zoom)
m.add_layer(t)
m |
Can localtileserver visualize an image in a requester-pay S3 bucket, like the NAIP imagery on AWS? Rasterio can read the image, but it seems localtileserver can't render it.
The text was updated successfully, but these errors were encountered: