Now we are ready to download images running along an entire street. PrevImage.append((met_lis,Head)) #append new Pano ID to list of images Urllib.urlretrieve(MyUrl, os.path.join(SaveLoc,fi)) If (met_lis,Head) not in PrevImage and met_lis is not None: #PrevImage is global list Met_lis = list(MetaParse(MetaUrl)) #does not grab image if no date #print MyUrl, MetaUrl #can check out image in browser to adjust size, fov to needs MetaUrl = base + r"/metadata" + size + end PrevImage = #Global list that has previous images sampled, memoization kindofĭef GetStreetLL(Lat,Lon,Head,File,SaveLoc): Return (jsonData,jsonData) #sometimes it does not have a date! (With a free account you can IIRC get 25,000 images in a day, but the meta-queries count against that as well.) def MetaParse(MetaUrl): If you are doing a ton of images you may limit the size of PrevImage to a certain amount, but it is no problem doing a few thousand images as is. Then if you have already downloaded that image once, the second GetStreetLL function will not download it again, as it checks the PrevImage list. To prevent that, we do a sort of memoization, where we grab the meta-data first, stuff it in a global list PrevImage. Because if you submit just a slightly different set of lat-lon, google will just download the same image again. The first, MetaParse, grabs the date (Month and Year) and pano_id from a particular street view image. So first we will import the necessary libraries we are using, then will globally define your user key and the download folder you want to save the streetview images into. It is a bit more complicated though, because when you base it off an address you do not need to worry about drawing the same image twice. For a different project I sampled images running along an entire street, so figured I would share that code. I’ve previously written about grabbing Google Streetview images given a particular address.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |