Sun Shadow Volume (3D Analyst)

License Level:BasicStandardAdvanced

Summary

Creates closed volumes that model shadows cast by each feature using sunlight for a given date and time.

Usage

Syntax

SunShadowVolume_3d (in_features, start_date_and_time, out_feature_class, {adjusted_for_dst}, {time_zone}, {end_date_and_time}, {iteration_interval}, {iteration_unit})
ParameterExplanationData Type
in_features
[in_features,...]

The multipatch features that will be used to model shadows. Polygon and line features can also be used if they are added as an extruded 3D layer.

Feature Layer
start_date_and_time

The date and time that the trajectory of sunlight will be calculated for modeling the shadows.

Date
out_feature_class

The multipatch feature class that will store the resulting shadow volumes.

Feature Class
adjusted_for_dst
(Optional)

Specifies if time value is adjusted for Daylight Savings Time (DST).

  • ADJUSTED_FOR_DSTDST is observed.
  • NOT_ADJUSTED_FOR_DSTDST is not observed. This is the default.
Boolean
time_zone
(Optional)

The time zone in which the participating input is located. The default setting is the time zone to which the operating system is set.

String
end_date_and_time
(Optional)

The final date and time for calculating sun position. If only a date is provided, the final time is presumed to be sunset.

Date
iteration_interval
(Optional)

The value used to define the iteration of time from the start date.

Double
iteration_unit
(Optional)

The unit that defines the iteration value applied to the Start Date and Time.

  • DAYSIteration value will represent days. This is the default.
  • HOURSIteration value will represent one or more hours.
  • MINUTESIteration value will represent one or more minutes.
String

Code Sample

SunShadowVolume example 1 (Python window)

The following sample demonstrates the use of this tool in the Python window:

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 example 2 (stand-alone script)

The following sample demonstrates the use of this tool in a stand-alone Python script:

'''*********************************************************************
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)

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: Requires 3D Analyst
ArcGIS for Desktop Standard: Requires 3D Analyst
ArcGIS for Desktop Advanced: Requires 3D Analyst
11/8/2012