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
def get_object_size(vue_object): | |
""" Takes a input Vue object, gets it's bounding box, then does the | |
math to get the XYZ size of the object. Returns a X,Y,Z tuple of | |
the object size. | |
""" | |
bounding_box = vue_object.GetBoundingBox() | |
bb_min = bounding_box.GetMin() | |
bb_max = bounding_box.GetMax() | |
# Build our tuple of object XYZ size |
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
terr_width = 3576 | |
terr_height = 4440 | |
terr_min_elev = -6.0801 | |
terr_max_elev = 28.20632 | |
terr_cell_res = 3.09129 | |
terr_z_elev = -6.083407 | |
terr_name = "NC_Kitty_Hawk_DEV" | |
def get_object_size(vue_object): |
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
def dd_to_dms(dd): | |
"""Convert a coordinate in decimal degrees to a tuple of (deg, min, sec)""" | |
is_positive = dd >= 0 | |
dd = abs(dd) | |
minutes,seconds = divmod(dd*3600,60) | |
degrees,minutes = divmod(minutes,60) | |
degrees = degrees if is_positive else -degrees | |
return (degrees,minutes,seconds) |
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
def translate_z(in_val, no_data, max_elev, min_elev): | |
""" Takes elevation Z values from raster and converts them to their | |
equivalent value on a scale of 0 to 1, where 0 is the minimum elevation | |
value of the raster dataset and 1 is the maximum. First add the min_z | |
absolute value to raster to bring lowest elevation value back up to zero. | |
""" | |
if in_val == no_data: | |
new_val = 0 | |
else: |
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
def raster_center(in_raster, gdb=""): | |
""" For given input raster, calculate center of bounding box and create a | |
point featureclass of the center | |
""" | |
raster = arcpy.Raster(in_raster) | |
center = arcpy.Point(raster.extent.XMin + (raster.extent.XMax - raster.extent.XMin)/2, | |
raster.extent.YMin + (raster.extent.YMax - raster.extent.YMin)/2) | |
if gdb: | |
gcenter = arcpy.PointGeometry(center, raster.spatialReference) |
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
def get_raster_corners(in_raster): | |
"""Get XY coordinates of four corners of a raster as dictionary""" | |
r = arcpy.Raster(in_raster) | |
corners = ["lowerLeft", "lowerRight", "upperLeft", "upperRight"] | |
corner_dict = {} | |
for corner in corners: | |
x = getattr(r.extent, "%s" % corner).X | |
y = getattr(r.extent, "%s" % corner).Y | |
corner_dict[corner] = [x, y] | |
return corner_dict |
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
def get_render_quality(in_quality): | |
""" | |
Takes a human-friendly render output quality and translates it into the | |
respective Vue setting. | |
""" | |
quality_dict = {"Preview" : VuePython.PRS_Preview, | |
"Final" : VuePython.PRS_Final} | |
if in_quality in quality_dict.keys(): |
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
# Position the sun | |
select_sun = SelectByName("Sun light") | |
sun = GetSelectedObjectByIndex(0) | |
# Sun position changes for each KOP | |
# Pitch and yaw are floats kept in a dict | |
sun_pitch = float(kop.get("SunPitch")) | |
sun_yaw = float(kop.get("SunYaw")) | |
sun.SetRotationAnglesV((sun_pitch, 0, sun_yaw), true) | |
Refresh() | |
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
class HaversineRaster(object): | |
"""Creates Haversine elevation raster for input into Vue | |
""" | |
def __init__(self, project_dir, project_name, raster): | |
self.project_dir = project_dir | |
self.project_name = project_name | |
self.in_raster = raster | |
self.props = v_utils.get_raster_props(raster) | |
self.hav_raster = self.create_haversine_raster() |
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 BeautifulSoup as bs | |
import urllib2, re | |
def FetchFipsCodes( ): | |
""" Fetches a table of FIPS codes form a EPA webpage and tosses them | |
into a dictionary """ | |
url = 'http://www.epa.gov/enviro/html/codes/state.html' | |
f = open('C:/temp/python/data/outputs/fips.csv', 'w') | |
# Fetch and parse the web page |
OlderNewer