I'm trying to implement some LiDAR data into my ArcGIS Pro work. The data I want to access is packaged into tiles, each hosted as their own feature in a single layer. These tiles contain a hyperlinked URL in the attribute table, which allow me to download the corresponding .laz files.
I want to download several hundred of these files, and I think Python would be a good choice to automate the downloading for me. Does anybody have pointers, tips, etc? I've seen mention of a 'for loop', would that be appropriate for this type of task?
would it be possible to supply the complete Download_L URL for testing?
R_
Sorry I wasn't checking this! I appreciate your help
https://download.fri.mnrf.gov.on.ca/api/api/Download/geohub/laz/utm16/1kmZ164040565102023L.copc.laz
Pretty basic, no error testing, but should get you started.
I do check to make sure the file hasn't already been downloaded:
import arcpy, os, urllib.request
fc = r'\\servername\sharename\folder\Pro_Test_map.gdb\TestFC' # input feature class with URL attribute
outfold = r'C:\Users\myusername\Desktop\tmp' #location to save laz files
with arcpy.da.SearchCursor(fc, ['Download_L']) as cursor: # establish search cursor with "Download_L" as url field
for row in cursor: # iterate trough list of files
infile = os.path.basename(row[0]) # get existing filename
outfile = outfold + os.sep + infile # set new filename/location
if not os.path.exists(outfile): # check to make sure file doesn't already exist
print("downloading - " + outfile)
urllib.request.urlretrieve(row[0], outfile) # download the file
else: print(outfile + ' already exists')
R_