POST
|
Absolutely, you can iterate through mosaics in a GDB. I couldn't make it work with Define Overviews for some reason but have done it lots of times especially with build pyramids and stats without having to go the nested route. What iterator are you using? What parameters did you set for your iterator? Can you give me a picture showing that?
... View more
03-07-2018
11:11 PM
|
1
|
1
|
390
|
POST
|
I have multiple mosaic datasets in a file geodatabase. I need to run the Define Overviews tool on all the mosaic datasets because I want to force the overviews on each mosaic dataset to go to 7 levels to suit my needs. However, when I try to iterate through the mosaic datasets with model builder I get an error after the first iteration, meaning it can't move on after the first mosaic dataset. Why doesn't the Define Overviews tool work with iterate? See image below for my model and the error message:
... View more
03-16-2017
04:55 PM
|
0
|
3
|
1042
|
POST
|
Hi Jake, Thank you for the suggestion! arcpy.da.Walk() was definitely needed. If this helps anyone else. This is what I used to get it working: import arcpy, os
basePath = r"\\nyx-galli\eGIS\Data\Raster\Imagery\Aerial\SGIC\2008_Mapcon"
db = os.path.join(basePath, r"BW.gdb")
walk = arcpy.da.Walk(basePath, datatype="RasterDataset", type="TIF")
for dirpath, dirnames, filenames in walk:
xPath = os.path.normpath(dirpath).split(os.sep)
if xPath[-1] == 'BW':
arcpy.env.workspace = dirpath
print dirpath
block = xPath[-2]
mosaicDataset = "{0}".format(block)
print mosaicDataset
if filenames:
rastersToAdd = ";".join(filenames)
print rastersToAdd
print "adding rasters for {0}".format(block)
arcpy.AddRastersToMosaicDataset_management(os.path.join(db, mosaicDataset), "Raster Dataset", rastersToAdd)
... View more
02-24-2017
03:26 PM
|
0
|
0
|
895
|
POST
|
My raster mosaic datasets are in a file gdb ordered by block. For example Block_470 and Block_480. My workspace has images ordered by block with subfolders with in each block. For example workspace Block_470 contains subfolders BW and RGB. This is the same for workspace Block_480. Meaning workspace Block_480 will also have subfolders BW and RGB. I need to add the tiff files in workspace Block_470/BW to raster mosaic dataset Block_470 and the tiff files in workspace Block_480/BW will need to be added to raster mosaic dataset Block_480. How can I iterate through so that the right tiff files in the subfolders go into the corresponding mosaic datasets? I was thinking something like this: import arcpy
workspaces = arcpy.ListWorkspaces("//nyx-galli/eGIS/Data/Raster/Imagery/Aerial/SGIC/2008_Mapcon/Block4*", "Folder")
datasets = arcpy.ListDatasets("D:/TestRasterMosaic/BW.gdb/Block_4*", "Mosaic")
for i in workspaces:
workspaces2 = arcpy.ListWorkspaces("", "Folder") This did not work for me:
... View more
02-23-2017
05:47 PM
|
0
|
2
|
2542
|
POST
|
I am working with the Mosaic Dataset Configuration Script (MDCS) on the Esri GitHub (GitHub - Esri/mdcs-py: MDCS is an acronym for Mosaic Dataset Configuration Script and is the entry point to a collection… ). A little more information on it can also be found here: https://www.arcgis.com/home/item.html?id=d1289a749b59477cb82228a09d1d0219 I have had success with running it on Command Prompt. However, what I really need is to make a tool out of the scripts to work in Model Builder. 1. How do I go about loading all the separate python script files into a tool? 2. How does the xml configuration file go into being used by a tool? 3. Do they all need to be inputs to MDCS.py? 4. Can this be done in a script tool or does it need to be done in a python toolbox tool? Any help would be greatly appreciated. Thank you.
... View more
02-08-2017
02:35 PM
|
0
|
1
|
1536
|
POST
|
I have a piece of working python code that I am looking to make more efficient. The code is trying to model vegetation change based on 4 rasters containing data on potential evapotranspiration, climate moisture index, precipitation, and summer precipitation. I also have a base vegetation raster that will have its values updated based on a set of conditions depending on values of the 4 rasters above at each cell. I have no idea how to do this without going through the rasters cell by cell because I have to know the cell values for all layers in order for the conditions to work on the cells of the vegetation layer. What is a better way of doing this? Code below: import arcpy
import numpy
inRasPE = arcpy.Raster("C:/VegModel/CCSSRawData.gdb/pe100Year2")
inRasCMI = arcpy.Raster("C:/VegModel/CCSSRawData.gdb/cmi100Year2")
inRasPCP = arcpy.Raster("C:/VegModel/CCSSRawData.gdb/pcp100Year2")
inRasSPP = arcpy.Raster("C:/VegModel/CCSSRawData.gdb/spp100Year2")
#inRasVeg = arcpy.Raster("C:/VegModel/CCSSRawData.gdb/vegnormrs100") #To be used the first time.
inRasVeg = arcpy.Raster("C:/VegModel/CCSSRawData.gdb/veg100Year1Revise3")
lowerLeft = arcpy.Point(inRasVeg.extent.XMin, inRasVeg.extent.YMin)
cellSize = inRasVeg.meanCellWidth
inArrayPE = arcpy.RasterToNumPyArray(inRasPE)
inArrayCMI = arcpy.RasterToNumPyArray(inRasCMI)
inArrayPCP = arcpy.RasterToNumPyArray(inRasPCP)
inArraySPP = arcpy.RasterToNumPyArray(inRasSPP)
inArrayVeg = arcpy.RasterToNumPyArray(inRasVeg, nodata_to_value = 0)
rasHeight, rasWidth = inArrayVeg.shape
for i in range(0, rasHeight):
for j in range(0, rasWidth):
value1 = inArrayPE[i, j]
value2 = inArrayVeg[i, j]
value3 = inArrayCMI[i, j]
if value1 <= 760:
if value2 == 11 and value3 < 0:
value2 = 21
inArrayVeg[i, j] = value2
elif value2 == 12 and value3 < 0:
value2 = 22
inArrayVeg[i, j] = value2
elif value2 == 13 and value3 < 0:
value2 = 23
inArrayVeg[i, j] = value2
elif value2 == 14 and value3 < 0:
value2 = 24
inArrayVeg[i, j] = value2
elif value2 == 15 and value3 < 0:
value2 = 25
inArrayVeg[i, j] = value2
elif value2 == 16 and value3 < 0:
value2 = 26
inArrayVeg[i, j] = value2
elif value2 == 21 and value3 < -150:
value2 = 41
inArrayVeg[i, j] = value2
elif value2 == 22 and value3 < -150:
value2 = 42
inArrayVeg[i, j] = value2
elif value2 == 23 and value3 < -150:
value2 = 43
inArrayVeg[i, j] = value2
elif value2 == 24 and value3 < -150:
value2 = 44
inArrayVeg[i, j] = value2
elif value2 == 25 and value3 < -40:
value2 = 26
inArrayVeg[i, j] = value2
elif value2 == 26 and value3 < -80:
value2 = 24
inArrayVeg[i, j] = value2
elif value2 == 31 and value3 < -260:
value2 = 41
inArrayVeg[i, j] = value2
elif value2 == 32 and value3 < -260:
value2 = 42
inArrayVeg[i, j] = value2
elif value2 == 33 and value3 < -260:
value2 = 43
inArrayVeg[i, j] = value2
elif value2 == 34 and value3 < -260:
value2 = 44
inArrayVeg[i, j] = value2
elif value2 == 35 and value3 < -220:
value2 = 36
inArrayVeg[i, j] = value2
elif value2 == 36 and value3 < -250:
value2 = 34
inArrayVeg[i, j] = value2
elif value2 == 41 and value3 < -300:
value2 = 51
inArrayVeg[i, j] = value2
elif value2 == 42 and value3 < -300:
value2 = 52
inArrayVeg[i, j] = value2
elif value2 == 43 and value3 < -300:
value2 = 53
inArrayVeg[i, j] = value2
elif value2 == 44 and value3 < -300:
value2 = 54
inArrayVeg[i, j] = value2
elif value2 == 51 and value3 < -400:
value2 = 56
inArrayVeg[i, j] = value2
elif value2 == 53 and value3 < -440:
value2 = 52
inArrayVeg[i, j] = value2
elif value2 == 54 and value3 < -320:
value2 = 53
inArrayVeg[i, j] = value2
elif value2 == 56 and value3 < -440:
value2 = 57
inArrayVeg[i, j] = value2
elif value1 > 760:
value4 = inArrayPCP[i, j]
value5 = inArraySPP[i, j]
sixtyThree = -37.298 + (0.027 * value4) + (0.004 * value1) + (70.895 * value5)
sixtyFour = -29.53 + (0.001 * value4) + (0.007 * value1) + (79.182 * value5)
sixtyFive = -73.987 + (0.002 * value4) + (0.04 * value1) + (114.753 * value5)
sixtySix = -67.219 + (0.031 * value4) + (0.017 * value1) + (121.6 * value5)
sixtySeven = -190.354 + (0.102 * value4) + (0.023 * value1) + (310.128 * value5)
seventyFour = -252.386 + (0.163 * value4) + (0.01 * value1) + (399.599 * value5)
isMax = sixtyThree
if sixtyFour > isMax:
isMax = sixtyFour
if sixtyFive > isMax:
isMax = sixtyFive
if sixtySix > isMax:
isMax = sixtySix
if sixtySeven > isMax:
isMax = sixtySeven
if seventyFour > isMax:
isMax = seventyFour
if value2 == 52 or value2 == 53 or value2 == 54 or value2 == 63 or value2 == 64 or value2 == 65 or value2 == 66 or value2 == 67 or value2 == 74:
if isMax == sixtyThree:
value2 = 63
inArrayVeg[i, j] = value2
elif isMax == sixtyFour:
value2 = 64
inArrayVeg[i,j] = value2
elif isMax == sixtyFive:
value2 = 65
inArrayVeg[i, j] = value2
elif isMax == sixtySix:
value2 = 66
inArrayVeg[i, j] = value2
elif isMax == sixtySeven:
value2 = 67
inArrayVeg[i, j] = value2
elif isMax == seventyFour:
value2 = 74
inArrayVeg[i, j] = value2
elif value2 == 11 and value3 < 0:
value2 = 21
inArrayVeg[i, j] = value2
elif value2 == 12 and value3 < 0:
value2 = 22
inArrayVeg[i, j] = value2
elif value2 == 13 and value3 < 0:
value2 = 23
inArrayVeg[i, j] = value2
elif value2 == 14 and value3 < 0:
value2 = 24
inArrayVeg[i, j] = value2
elif value2 == 15 and value3 < 0:
value2 = 25
inArrayVeg[i, j] = value2
elif value2 == 16 and value3 < 0:
value2 = 26
inArrayVeg[i, j] = value2
elif value2 == 21 and value3 < -150:
value2 = 41
inArrayVeg[i, j] = value2
elif value2 == 22 and value3 < -150:
value2 = 42
inArrayVeg[i, j] = value2
elif value2 == 23 and value3 < -150:
value2 = 43
inArrayVeg[i, j] = value2
elif value2 == 24 and value3 < -150:
value2 = 44
inArrayVeg[i, j] = value2
elif value2 == 25 and value3 < -40:
value2 = 26
inArrayVeg[i, j] = value2
elif value2 == 26 and value3 < -80:
value2 = 24
inArrayVeg[i, j] = value2
elif value2 == 31 and value3 < -260:
value2 = 41
inArrayVeg[i, j] = value2
elif value2 == 32 and value3 < -260:
value2 = 42
inArrayVeg[i, j] = value2
elif value2 == 33 and value3 < -260:
value2 = 43
inArrayVeg[i, j] = value2
elif value2 == 34 and value3 < -260:
value2 = 44
inArrayVeg[i, j] = value2
elif value2 == 35 and value3 < -220:
value2 = 36
inArrayVeg[i, j] = value2
elif value2 == 36 and value3 < -250:
value2 = 34
inArrayVeg[i, j] = value2
elif value2 == 41 and value3 < -300:
value2 = 51
inArrayVeg[i, j] = value2
elif value2 == 42 and value3 < -300:
value2 = 52
inArrayVeg[i, j] = value2
elif value2 == 43 and value3 < -300:
value2 = 53
inArrayVeg[i, j] = value2
elif value2 == 44 and value3 < -300:
value2 = 54
inArrayVeg[i, j] = value2
elif value2 == 51 and value3 < -400:
value2 = 56
inArrayVeg[i, j] = value2
elif value2 == 56 and value3 < -440:
value2 = 57
inArrayVeg[i, j] = value2
newRaster = arcpy.NumPyArrayToRaster(inArrayVeg, lowerLeft, cellSize, value_to_nodata = 0)
newRaster.save("C:/VegModel/Revise.gdb/veg100Year2Revise3")
... View more
01-10-2017
01:19 PM
|
0
|
1
|
1133
|
Title | Kudos | Posted |
---|---|---|
1 | 03-07-2018 11:11 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|