Last active
February 26, 2019 21:57
-
-
Save OterLabb/4fcf6615bcf3169b5ba6df56e85765ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sc = arcpy.SearchCursor(selectFishnets) | |
# Create empty list for kmz names | |
kmzList = [] | |
# Download for each feature in selected fishnets feature | |
for row in sc: | |
# Get extent for each feature | |
geom = row.shape | |
extents = [] | |
extents.append(geom.extent) | |
# Find extents of each feature in selected fishnets | |
XMin = min([e.XMin for e in extents]) | |
XMax = max([e.XMax for e in extents]) | |
YMin = min([e.YMin for e in extents]) | |
YMax = max([e.YMax for e in extents]) | |
line = str(XMin) + ',' + str(YMin) + ',' + str(XMax) + ',' + str(YMax) | |
x_pixel_size = (XMax - XMin) / inImageWidth | |
y_pixel_size = ((YMax - YMin) / inImageHeight) * -1 | |
# Set the download url format | |
imageFormat = 'png' | |
urlGetImage = '{0}/export?bbox={1}&bboxSR=&format={2}&f=kmz&dpi={3}&size={4},{5}'.format(inUrl, line, | |
imageFormat, inDPI, inImageWidth, inImageHeight) | |
# Print status of downloading status | |
arcpy.AddMessage("Downloading {0} of {1}".format(firstCount,count)) | |
firstCount += 1 | |
# Downloading .kmz files | |
randomFileName = str(uuid.uuid4()) | |
kmzList.append(randomFileName) | |
kmzFile = os.path.join(tempFolder, randomFileName + '.kmz') | |
urllib.request.urlretrieve(urlGetImage, kmzFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment