71 aws s3
Loading geospatial datasets from an AWS S3 bucket
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# %pip install -U leafmap
# %pip install -U leafmap
In [ ]:
Copied!
# %pip install -U boto3
# %pip install -U boto3
To Be able to run this notebook you'll need to have AWS credential available as environment variables. Uncomment the following lines to set the environment variables.
In [ ]:
Copied!
# import os
# os.environ["AWS_ACCESS_KEY_ID"] = "YOUR AWS ACCESS ID HERE"
# os.environ["AWS_SECRET_ACCESS_KEY"] = "YOUR AWS ACCESS KEY HERE"
# import os
# os.environ["AWS_ACCESS_KEY_ID"] = "YOUR AWS ACCESS ID HERE"
# os.environ["AWS_SECRET_ACCESS_KEY"] = "YOUR AWS ACCESS KEY HERE"
In [ ]:
Copied!
import leafmap
import leafmap
In this example, we will use datasets from the Maxar Open Data Program on AWS.
In [ ]:
Copied!
BUCKET = "maxar-opendata"
FOLDER = "events/Kahramanmaras-turkey-earthquake-23/"
BUCKET = "maxar-opendata"
FOLDER = "events/Kahramanmaras-turkey-earthquake-23/"
List all the datasets in the bucket. Specify a file extension to filter the results if needed.
In [ ]:
Copied!
items = leafmap.s3_list_objects(BUCKET, FOLDER, ext=".tif")
items[:10]
items = leafmap.s3_list_objects(BUCKET, FOLDER, ext=".tif")
items[:10]
Visualize raster datasets from the bucket.
In [ ]:
Copied!
m = leafmap.Map()
m.add_cog_layer(items[2], name="Maxar")
m
m = leafmap.Map()
m.add_cog_layer(items[2], name="Maxar")
m
Download a raster dataset from the bucket.
In [ ]:
Copied!
leafmap.s3_download_file(items[0], outfile="maxar.tif")
leafmap.s3_download_file(items[0], outfile="maxar.tif")
Download a list of raster datasets from the bucket.
In [ ]:
Copied!
leafmap.s3_download_files(items[:2], outdir="maxar")
leafmap.s3_download_files(items[:2], outdir="maxar")