rishabh-sat's picture
Upload walkability project (rest) (part 11)
7b0de7a verified
Raw History Blame Contribute Delete
872 Bytes
import sys, urllib.request, xml.etree.ElementTree as ET, re
state=sys.argv[1]
base="https://lilawildlife.blob.core.windows.net/lila-wildlife?restype=container&comp=list&prefix=lcmcvpr2019/cvpr_chesapeake_landcover/&maxresults=5000"
marker=""; out=[]
while True:
url=base+("&marker="+marker if marker else "")
root=ET.fromstring(urllib.request.urlopen(url).read())
for b in root.iter("Blob"):
n=b.find("Name").text; s=int(b.find("Properties/Content-Length").text)
if re.search(rf"/{state}_1m_\d{{4}}_extended-debuffered-(train|val|test)_tiles/.*_(naip-new|nlcd|lc)\.tif$",n):
out.append((n,s))
nm=root.find("NextMarker")
if nm is None or not nm.text: break
marker=nm.text
with open(f"{state}_files.txt","w") as f:
for n,s in out: f.write(f"{n}\t{s}\n")
print(len(out),"files",round(sum(s for _,s in out)/1e9,1),"GB")