import os
import geopandas as gpd
import pandas as pd
import boto3
os.system('cat my_roi_4326.geojson | supermercado burn 18 | mercantile shapes | fio collect > my_roi_4326_outtiles.geojson')
tiles = gpd.read_file('my_roi_4326_outtiles.geojson')
tiles.id=tiles.id.map(lambda x: x.lstrip('(').rstrip(')'))
tms=tiles.id.str.split(',', expand=True)
tms[0]=tms[0].str.strip()
tms[1]=tms[1].str.strip()
tms[2]=tms[2].str.strip()
tms.to_csv('my_roi_4326_outtiles.csv',index=False)
s3 = boto3.resource('s3')
s3_client = boto3.client('s3')
outpath='mypath'
BUCKET_NAME = 's3tiles'
for i in range(0,len(tms)):
KEY = 'tiles/jobid/'+str(tms.iloc[i][2])+'/'+str(tms.iloc[i][0])+'/'+str(tms.iloc[i][1])+'.png'
if not os.path.isdir(outpath+str(tms.iloc[i][2])+'/'+str(tms.iloc[i][0])+'/'):
os.makedirs(outpath+str(tms.iloc[i][2])+'/'+str(tms.iloc[i][0])+'/')
try:
s3_client.download_file(BUCKET_NAME,KEY,outpath+str(tms.iloc[i][2])+'/'+str(tms.iloc[i][0])+'/'+str(tms.iloc[i][1])+'.png')
except Exception as e:
print(e)
Last active
November 24, 2018 21:31
-
-
Save shaystrong/4f03c1745957bfcadde7f2954bfe9c7c to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment