太阳阴影体 (3D Analyst)

许可等级:BasicStandardAdvanced

摘要

利用每个要素在给定日期和时间的光照条件下所投射出的模型阴影来创建闭合体。

用法

语法

SunShadowVolume_3d (in_features, start_date_and_time, out_feature_class, {adjusted_for_dst}, {time_zone}, {end_date_and_time}, {iteration_interval}, {iteration_unit})
参数说明数据类型
in_features
[in_features,...]

用于模拟阴影的多面体要素。如果面要素和线要素添加为一个拉伸 3D 图层,则也可使用它们。

Feature Layer
start_date_and_time

将计算阳光轨线来对阴影进行建模的日期和时间。

Date
out_feature_class

存储生成的阴影体的多面体要素类。

Feature Class
adjusted_for_dst
(可选)

指定时间值是否调整为夏令时 (DST)。

  • ADJUSTED_FOR_DST遵守 DST。
  • NOT_ADJUSTED_FOR_DST不遵守 DST。这是默认设置。
Boolean
time_zone
(可选)

参与输入所在的时区。默认设置是操作系统所设置的时区。

String
end_date_and_time
(可选)

用于计算太阳位置的最终日期和时间。如果只提供一个日期,则假设最终时间为日落。

Date
iteration_interval
(可选)

用于定义从开始日期起的时间迭代的值。

Double
iteration_unit
(可选)

定义应用到起始日期和时间的迭代值的单位。

  • DAYS迭代值将表示天数。这是默认设置。
  • HOURS迭代值将表示一个或几个小时。
  • MINUTES迭代值将表示一分钟或几分钟。
String

代码实例

太阳阴影体 (SunShadowVolume) 示例 1(Python 窗口)

下面的示例演示了如何在 Python 窗口中使用此工具:

import arcpy
from arcpy import env

arcpy.CheckOutExtension('3D')
env.workspace = 'C:/data'
arcpy.SunShadowVolume_3d(['sample.fgdb/buildings_1', 'buildings_2.shp'], 
                         '12/25/2011 10:00 AM', 'shadows_dec25.shp', 
                         'ADJUSTED_FOR_DST', 'Eastern_Standard_Time', 
                         '12/25/2011 3:00 PM', 'HOURS', 1)
太阳阴影体 (SunShadowVolume) 示例 2(独立脚本)

下面的示例演示了如何在独立 Python 脚本中使用此工具:

'''*********************************************************************
Name: Model Shadows For GeoVRML Models
Description: Creates a model of the shadows cast by GeoVRML models 
             imported to a multipatch feature class for a range of dates
             and times. A range of times from the start time and end 
             time can also be specified by setting the EnforceTimes 
             Boolean to True. This sample is designed to be used in a 
             script tool.
*********************************************************************'''
# Import system modules
import arcpy
from datetime import datetime, time, timedelta

#*************************  Script Variables  **************************
inFiles = arcpy.GetParameterAsText(0) # list of input features
spatialRef = arcpy.GetParameterAsText(1) # list of GeoVRML files
outFC = arcpy.GetParameterAsText(2) # multipatch from 3D files
inTimeZone = arcpy.GetParameterAsText(3) # time zone
startDate = arcpy.GetParameter(4) # starting date as datetime
endDate = arcpy.GetParameter(5) # ending date as datetime
dayInterval = arcpy.GetParameter(6) # day interval as long (0-365)
minInterval = arcpy.GetParameter(7) # minute interval as long (0-60)
enforceTime = arcpy.GetParameter(8) # minute interval as Boolean
outShadows = arcpy.GetParameterAsText(9) # output shadow models
outIntersection = arcpy.GetParameterAsText(10) # shadow & bldg intersection

# Function to find all possible date/time intervals for shadow modelling
def time_list():
    dt_result = [startDate]
    if dayInterval:
        if endDate: #Defines behavior when end date is supplied
            while startDate < endDate:
                startDate += timedelta(days=dayInterval)
                dt_result.append(startDate)
            dt_result.append(endDate)
        else: # Behavior when end date is not given
            daymonthyear = datetime.date(startDate)
            while startDate <= datetime(daymonthyear.year, 12, 31, 23, 59):
                startDate += timedelta(days=dayInterval)
                dt_result.append(startDate)
    return dt_result

try:
    arcpy.CheckOutExtension('3D')
    importFC = arcpy.CreateUniqueName('geovrml_import', 'in_memory')
    # Import GeoVRML files to in-memory feature
    arcpy.ddd.Import3DFiles(inFiles, importFC, 'ONE_FILE_ONE_FEATURE', 
                            spatialRef, 'Z_IS_UP', 'wrl')
    # Ensure that building models are closed
    arcpy.ddd.EncloseMultiPatch(importFC, outFC, 0.05)
    # Discard in-memory feature
    arcpy.management.Delete(importFC)
    dt_result = time_list()
    for dt in dt_result:
        if dt == dt_result[0]:
            shadows = outShadows
        else:
            shadows = arcpy.CreateUniqueName('shadow', 'in_memory')
        arcpy.ddd.SunShadowVolume(outFC, dt, shadows, 'ADJUST_FOR_DST', 
                                  inTimeZone, '', minInterval, 'MINUTES')
        if dt is not dt_result[0]:
            arcpy.management.Append(shadows, outShadows)
            arcpy.management.Delete(shadows)
    arcpy.ddd.Intersect3D(outFC, outIntersection, outShadows, 'SOLID')
    arcpy.CheckInExtension('3D')
except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = "PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}"\
          .format(tbinfo, str(sys.exc_info()[1]))
    msgs = "ArcPy ERRORS:\n {0}\n".format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)

环境

相关主题

许可信息

ArcGIS for Desktop Basic:需要 3D Analyst
ArcGIS for Desktop Standard:需要 3D Analyst
ArcGIS for Desktop Advanced:需要 3D Analyst
9/15/2013