Last active
December 20, 2015 02:29
-
-
Save chadcooper/6056655 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import arcpy | |
in_raster = r"\\psf\Home\Documents\ArcGIS\Default.gdb\rastercalc13" | |
in_raster_obj = arcpy.Raster(in_raster) | |
arcpy.env.extent = in_raster | |
arcpy.env.cellSize = in_raster | |
arcpy.env.overwriteOutput = 1 | |
# Raster already projected earlier in CreateProject.py process | |
arcpy.CheckOutExtension("Spatial") | |
# 2 - Con to make values > 0 = 1, else 0, use this next | |
ones_zeros_con = arcpy.sa.Con(in_raster_obj, 1, 0, "VALUE > 0") | |
# 3 - Extract values = 1 to new raster, use this next | |
extracted_ones = arcpy.sa.ExtractByAttributes(ones_zeros_con, "VALUE = 1") | |
# 4 - Do Euc Dist on extent of in_raster, using the land values of 1. This will calc the nearest distance to shore | |
# for every cell that represents water, not land | |
euc_dist = arcpy.sa.EucDistance(extracted_ones) | |
# 5 - Flip the ED values and make them go from 0->100 instead of 0->max_elev. Do this by multiplying each cell by | |
# (100/-max_elev) | |
max_elev = euc_dist.maximum | |
conv_to_hundred_con = arcpy.sa.Con(euc_dist, (euc_dist * (100/-max_elev)), euc_dist, "VALUE > 0") | |
# 6 - Add 100 to every cell that is less than 100, which flips the numbers offshore and makes the shoreline 100m and | |
# as you go out to sea, the depths taper down to 0 | |
con_reverse_slope = arcpy.sa.Con(conv_to_hundred_con, conv_to_hundred_con + 100, conv_to_hundred_con, "VALUE < 100") | |
# 7 - For values = 100 (land only values), add the values from original in_raster back | |
slope_plus_orig_land_con = arcpy.sa.Con(con_reverse_slope, con_reverse_slope + in_raster_obj, con_reverse_slope, | |
"VALUE = 100") | |
# Save. Now have a raster where lowest point underwater is very close to 0 (positive), shoreline (sea level) is 100, and | |
# all land elevation values are (in_raster + 100). Now in Vue set sea level to 100, subtract 100 from the radius | |
# of the earth, add 100m to camera and wtgs, and all is good. We get a nice slope down from shore to the ocean | |
# botton and no abyss which results in the sea being dark blue | |
slope_plus_orig_land_con.save(r"\\psf\Home\Documents\ArcGIS\Default.gdb\scripted_slope_cape1") | |
arcpy.CheckInExtension("Spatial") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment