Exemple #1
0
            superf_kurowski.append(values)
        elif values <= ELA and values > kurowski:
            superf_en_ELA.append(values)
        elif values > ELA and values <= kurowski:
            superf_kurowski.append(values)
        else:
            pass

# Get the maximum surface value within the list
    ela = max(superf_en_ELA)
    kur = max(superf_kurowski)

    #Get the altitude value that corresponds to the surface
    for altitudes, superficies in dictionary.iteritems():
        if superficies == ela:
            elaok = altitudes + (interval / 2)
            outline = os.path.join(files, desc.baseName + "AAR.shp")
            arcpy.Contour_3d(dem, outline, 100000, elaok)
            arcpy.AddMessage("The ELA AAR is:")
            arcpy.AddMessage(elaok)
            break
    for altitudes, superficies in dictionary.iteritems():
        if superficies == kur:
            elaok = altitudes + (interval / 2)
            outline = os.path.join(files, desc.baseName + "MGE.shp")
            arcpy.Contour_3d(dem, outline, 100000, elaok)
            arcpy.AddMessage("The ELA MGE is:")
            arcpy.AddMessage(elaok)
            break
    fo.close  # Close the .txt file
Exemple #2
0
                    try:#both treat comma and point decimals
                        segundovalor.append(int(c.split('.')[0]))
                    except:
                        segundovalor.append(int(c.split(',')[0]))
                    break
                except:
                    pass

# AA Calculation
    superf_total=max(segundovalor)
    resta=[int(x)-int(y) for (x,y) in zip(segundovalor[1:], segundovalor[0:])]
    multiplicacion=[int(x)*int (y) for (x,y) in zip (resta,list_altitudes)]
    finalmulti=sum(multiplicacion)
    resultAA=int(int(finalmulti)/int(superf_total))
    outlineAA=os.path.join(files,desc.baseName+"AA.shp")
    arcpy.Contour_3d(dem,outlineAA,100000,resultAA)
    arcpy.AddMessage("The ELA AA is:")
    arcpy.AddMessage(resultAA)

# AABR Calculation
    refinf=minalt
    valores_multi=[]
    valorAABR=[x*(y - refinf) for (x,y) in zip (resta, list_altitudes)]
    for valoracion in valorAABR:
        if valoracion<0:
            valores_multi.append(int (valoracion*br))
        else:
            valores_multi.append(int (valoracion))
    valorAABRfinal=sum (valores_multi)
    while valorAABRfinal > 0:
        refinf=refinf+interval
Exemple #3
0
# Parámtetros de entrada
cotaRio = 250  # cota del rio
hCresta = 225  # altura de la cresta
areaCol = 115800  # área parabólica
velCol = 148  # m/s  (532800 m/h) velocidad de la columna de agua según la Fórmula de Chezy-Manning (rugosidad, pendiente, radio hidráulico)
zInt = 10  # ¿Cada cuánto se se generan las curvas?
"""Missión: Determinar el polígono/cota de inundación (altura alcanzada por el embalse) de acuerdo a
las condiciones de llenado definidas por el caudal neto de entrada y el tiempo de simulación.
"""

# Se establecen los parámetros de la simulación
cotaEmb = cotaRio + hCresta  # 475
caudalNeto = velCol * areaCol  # 17138400 m3/s caudal de la columna de agua m3/s

# Generan las curvas de nivel a partir del DEM
cNivel = arcpy.Contour_3d(dem, "curvasNivel", zInt, cotaEmb)

# Añadir campo longitud
arcpy.AddGeometryAttributes_management(cNivel, "LENGTH")

# Crear una lista con las curvas de nivel
listaCurvas = list(
    set([row[0] for row in arcpy.da.SearchCursor(cNivel, ["Contour"])]))
listaCurvas.sort()

# Realizar el análisis para cada curva
i = 0
for cotaAnalisis in listaCurvas:
    if i < 15 and i > 10:
        # Generar poligono de inundacion
        whereClause = "Contour = %s" % cotaAnalisis
Exemple #4
0
"""
	TIN to DEM
	The cell size of the new DEM is 50 meters, values are in the 
	float type, and the methos used to raster the DEM is linear
	interpolation 
"""
arcpy.TinRaster_3d(in_tin=r"chp12data.gdb/tin", out_raster="demFromTIN", \
                   data_type="FLOAT", method="LINEAR", \
                   sample_distance="CELLSIZE 50",z_factor="1")

# Create contour lines ##################################################################
"""
	The input is "dem" and the output is "contour".
	The contour is in 10 meter intervals and starts from 330 meters.
"""
arcpy.Contour_3d(in_raster="dem", out_polyline_features=" contour", \
                 contour_interval="10", base_contour="330", z_factor="1")

# Create slope raster ###################################################################
# the input is DEM, and slope is in the unit of degrees
slopely = arcpy.sa.Slope("dem", "DEGREE")
# save the slope layer into geodatabase (path has been set above)
slopely.save("slope")

# Create aspect raster ##################################################################
aspectly = arcpy.sa.Aspect("dem")
aspectly.save("aspect")

# Create flow direction raster ##########################################################
"""
	Create flow direction with "dem" as input.  The "NORMAL" argument means
	edge cells are not forced outward, but follow normal flow rules.
                    value += n[k]
            if count > 0:
                c = abs(float(x)-float(value)/float(count))
                c_max = max(c_max,c)
                copy_array[i, j] = c

#Reclassification of TPI by choosen number at the start of the script
print "Reclasification of TPI values"
if number < c_max:
    for i in range(1, len(copy_array[:, 1])-1):
        for j in range(1, len(copy_array[1, :])-1):
            x = copy_array[i, j]
            x = min(x,number)
            copy_array[i, j] = x

#Convert array to reclassified TPI raster
TPI = arcpy.NumPyArrayToRaster(copy_array, arcpy.Point(mx,my),raster.meanCellWidth,raster.meanCellHeight)
TPI = SetNull(TPI, TPI, "VALUE = -9999")
arcpy.DefineProjection_management(TPI, coord_sys)

#Calculation of final raster
result = TPI * raster_gaus_small + (1 - TPI) * raster_gaus_big
arcpy.DefineProjection_management(result, coord_sys)

#Exporting result raster
arcpy.CopyRaster_management(result, output)

#Creation of contours
arcpy.Contour_3d(result, contour, interval, 0)

print "Done!"
Exemple #6
0
# -1 tif and tif>shp.
# 0 shp and it includes name field.
env.workspace = "F:/running/auto-zone/labs/hss/alps" # RE

# 1 contours
in_raster = "alps.tif" # RE
contour_interval = 30 # RE
base_contour = 0
out_contours = "xian1.shp"   # xian 1

# Check out the ArcGIS 3D Analyst extensionlicense
arcpy.CheckOutExtension("3D")

t1 = time.time()
#Exe Contours
arcpy.Contour_3d(in_raster,out_contours,contour_interval,base_contour)
elapsed1 = (time.time()-t1)

print("finish part 1------------------")
print("time:",elapsed1)

time.sleep(2)


# 2 cut
clip_features = "alpst.shp"  # mian 1 RE
out_features = "xian2_identity.shp"  # xian 2
xy_tolerance = ""

t2 = time.time()
# Execute Clip
Exemple #7
0
if __name__ == "__main__":
    arcpy.env.overwriteOutput = True

    # cale_raster = r"D:\Python\Test\Curs_DEM\dempm"
    # raster = arcpy.Raster(cale_raster)
    # print(raster)
    # matrice = arcpy.RasterToNumPyArray(raster, arcpy.Point(raster.extent.XMin, raster.extent.YMin),raster.width, raster.height, raster.noDataValue)
    # print(matrice)
    # print()

    arcpy.env.Overwrite = True
    # Contur
    env.workspace = r"D:\Python\Test\Curs_DEM"
    inRaster = "dempm"
    contourInterval = 10
    baseContour = 0
    outContours = "D:\Python\Test\Curs_DEM\contur1"
    arcpy.Contour_3d(inRaster, outContours, contourInterval, baseContour)

# Dem
# Name: Contour_Ex_02.py
# Description: Creates contours or isolines from a raster surface.
# Requirements: Spatial Analyst Extension
# Set local variables
inPointElevations = "C:/data/spots.shp spot_meters PointElevation"
inContours = "C:/data/contours.shp spot_meters Contour"
inFeatures = (r"D:\Python\Test\Curs_DEM\contur1.shp")
outRaster = r"D:\Python\Test\Curs_DEM\contur11.tif"

# Execute TopoToRaster
arcpy.TopoToRaster_3d(inFeatures, outRaster)
Slope_r = local_directory+"slope_r"
Aspect_r = local_directory+"aspect_r"
Final_r = local_directory+"final_r"
Final_OK = local_directory+"final_ok"

# Process: Mosaic To New Raster
arcpy.MosaicToNewRaster_management(local_directory+"srtm_34_02.tif;U:\\GIS_demos\\srtm_latest\\srtm_35_01.tif;U:\\GIS_demos\\srtm_latest\\srtm_35_02.tif", srtm_latest, "srtm_combined", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]", "16_BIT_SIGNED", "", "1", "LAST", "FIRST")

# Process: Project Raster
arcpy.ProjectRaster_management(srtm_combined, srtm_29902, "PROJCS['TM65_Irish_Grid',GEOGCS['GCS_TM65',DATUM['D_TM65',SPHEROID['Airy_Modified',6377340.189,299.3249646]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',200000.0],PARAMETER['False_Northing',250000.0],PARAMETER['Central_Meridian',-8.0],PARAMETER['Scale_Factor',1.000035],PARAMETER['Latitude_Of_Origin',53.5],UNIT['Meter',1.0]]", "NEAREST", "", "", "", "")

# Process: Clip
arcpy.Clip_management(srtm_29902, "17491.1419994107 19589.9279998709 334558.590000137 466919.308999998", srtm_clipped, Census2011_Province_Modified_shp, "-32768", "NONE", "NO_MAINTAIN_EXTENT")

# Process: Contour
arcpy.Contour_3d(srtm_clipped, contour_50_shp, "100", "0", "1")

# Process: Hillshade
arcpy.gp.HillShade_sa(srtm_clipped, hillshade__2_, "315", "45", "NO_SHADOWS", "1")

# Process: Slope
arcpy.gp.Slope_sa(srtm_clipped, slope__2_, "DEGREE", "1")

# Process: Reclassify
arcpy.gp.Reclassify_sa(slope__2_, "Value", "20 45 1", Slope_r, "NODATA")

# Process: Aspect
arcpy.gp.Aspect_sa(srtm_clipped, Aspect__2_)

# Process: Reclassify (2)
arcpy.gp.Reclassify_sa(Aspect__2_, "Value", "160 200 1", Aspect_r, "NODATA")