Watershed command are working right now. I regenerate outlet points and I could get the correct pour points.
In other hand, I followed another method. Instead using Zonal Statistics, I did iteratively for each outlet point as follows:
So, I have a fold containing all the outlet raster points whose values are the amounts of withdrawals upstream. Next step is using [cell statistics] to sum all these rasters, ignoring NO DATA values.
Thank you guys for the support.
Here is the code generated from Model Builder. Some parts are written in Portuguese.
---------------------------------------------------------------------------
Estatisticas de montante.py
Created on: 2012-09-14 22:14:50.00000
(generated by ArcGIS/ModelBuilder)
Usage: Estatisticas de montante > > > >
Description:
--------------------------------------------------------------------------->
Import arcpy module
import arcpy
Check out any necessary licenses
arcpy.CheckOutExtension("spatial")
Load required toolboxes
arcpy.ImportToolbox("Model Functions")
arcpy.ImportToolbox("C:/data/SOMA_OUT/1-Werisk.tbx")
Set Geoprocessing environments
arcpy.env.snapRaster = ""
arcpy.env.extent = ""
arcpy.env.cellSize = ""
Script arguments
Fozes_raster = arcpy.GetParameterAsText(0)
Campo_com_valores_de_0_ao_número_de_linhas__raster_fozes_ = arcpy.GetParameterAsText(1)
Shape_de_outorgas__exige_campo_com_nome_vazao_ = arcpy.GetParameterAsText(2)
Selecione_o_campo_e_o_tipo_de_estatística = arcpy.GetParameterAsText(3)
Direção_do_Escoamento = arcpy.GetParameterAsText(4)
Pasta_de_saída_de_arquivos = arcpy.GetParameterAsText(5)
Local variables:
Estat_n_ = Fozes_raster
Watersh_n_ = Estat_n_
Bacia_shp_n_ = Watersh_n_
outorgas_selecionadas = Bacia_shp_n_
Row_Count = outorgas_selecionadas
outorgas_na_bacia_n_ = Row_Count
Sum_table = outorgas_na_bacia_n_
Sum_table_com_o_campo = Sum_table
Sum_table_com_o_campo_e_com_o_valor = Sum_table_com_o_campo
Foz_Extraida_com_valor_da_soma_da_vazao = Sum_table_com_o_campo_e_com_o_valor
Est_n_lyr_lyr = Foz_Extraida_com_valor_da_soma_da_vazao
Copy_n_ras = Est_n_lyr_lyr
Est_n = Copy_n_ras
Ext_lyr_n_ = Sum_table
Valor_do_campo_da_foz_extraida = Ext_lyr_n_
Num_de_linhas = Fozes_raster
Value = Num_de_linhas
Campo = "VALUE"
Field_Name = "%Campo%"
Process: Get Count
arcpy.GetCount_management(Fozes_raster)
Process: For
arcpy.IterateCount_mb("1", Num_de_linhas, "1")
Process: Extract by Attributes
tempEnvironment0 = arcpy.env.scratchWorkspace
arcpy.env.scratchWorkspace = "C:\Users\PC\Documents\ArcGIS\Default.gdb"
tempEnvironment1 = arcpy.env.workspace
arcpy.env.workspace = "C:\Users\PC\Documents\ArcGIS\Default.gdb"
arcpy.gp.ExtractByAttributes_sa(Fozes_raster, "\"%Campo com valores de 0 ao número de >linhas (raster fozes)%\" = %n%", Estat_n_)
arcpy.env.scratchWorkspace = tempEnvironment0
arcpy.env.workspace = tempEnvironment1
Process: Watershed
arcpy.gp.toolbox = "C:/data/SOMA_OUT/1-Werisk.tbx";
Warning: the toolbox C:/data/SOMA_OUT/1-Werisk.tbx DOES NOT have an alias.
Please assign this toolbox an alias to avoid tool name collisions
And replace arcpy.gp.Watershed(...) with arcpy.Watershed_ALIAS(...)
arcpy.gp.Watershed(Direção_do_Escoamento, Estat_n_, Watersh_n_, Campo)
Process: Raster to Polygon
arcpy.RasterToPolygon_conversion(Watersh_n_, Bacia_shp_n_, "SIMPLIFY", "VALUE")
Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(Shape_de_outorgas__exige_campo_com_nome_vazao_, >"WITHIN", Bacia_shp_n_, "", "NEW_SELECTION")
Process: Get Count (2)
arcpy.GetCount_management(Shape_de_outorgas__exige_campo_com_nome_vazao_)
Process: Copy Features
arcpy.CopyFeatures_management(Shape_de_outorgas__exige_campo_com_nome_vazao_, >outorgas_na_bacia_n_, "", "0", "0", "0")
Process: Summary Statistics
tempEnvironment0 = arcpy.env.scratchWorkspace
arcpy.env.scratchWorkspace = "C:\Users\PC\Documents\ArcGIS\Default.gdb"
arcpy.Statistics_analysis(outorgas_na_bacia_n_, Sum_table, >Selecione_o_campo_e_o_tipo_de_estatística, "")
arcpy.env.scratchWorkspace = tempEnvironment0
Process: Make Raster Layer
tempEnvironment0 = arcpy.env.scratchWorkspace
arcpy.env.scratchWorkspace = "C:\Users\PC\Documents\ArcGIS\Default.gdb"
arcpy.MakeRasterLayer_management(Estat_n_, Ext_lyr_n_, "", "302545,967240849 >8506968,76613879 725280,246664134 8894612,97717014", "")
arcpy.env.scratchWorkspace = tempEnvironment0
Process: Get Raster Properties
arcpy.GetRasterProperties_management(Ext_lyr_n_, "MAXIMUM")
Process: Add Field
arcpy.AddField_management(Sum_table, Field_Name, "LONG", "", "", "", "", "NULLABLE", >"NON_REQUIRED", "")
Process: Calculate Field
arcpy.CalculateField_management(Sum_table_com_o_campo, "%Campo%", "%Valor do campo da foz >extraida%", "VB", "")
Process: Add Join
arcpy.AddJoin_management(Ext_lyr_n_, Campo, Sum_table, Campo, "KEEP_COMMON")
Process: Save To Layer File
arcpy.SaveToLayerFile_management(Ext_lyr_n_, Est_n_lyr_lyr, "")
Process: Copy Raster
arcpy.CopyRaster_management(Est_n_lyr_lyr, Copy_n_ras, "", "", "", "NONE", "NONE", "")
Process: Lookup
arcpy.gp.Lookup_sa(Copy_n_ras, "SUM_VAZAO", Est_n)