ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 合约
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

DataFrameTime

  • 摘要
  • 讨论
  • 属性
  • 方法概述
  • 方法
  • 代码实例

摘要

DataFrameTime 对象可用于访问数据框中启用了时间属性的图层管理操作。

讨论

DataFrameTime 对象提供了两种基本情景下的若干功能:

  • 第一种情况适用于发布时已启用了时间图层的地图文档,其设置已通过时间滑块选项对话框建立,并随地图文档一同保存。此种情况下,可使用现有属性进行自动输出。下面的示例 1 和示例 2 即为第一种情况。
  • 第二种情况适用于发布时不含启用时间图层的地图文档,但后续通过脚本添加了该时间图层,因而需要设置时间滑块选项,以便自动得到所需输出。下方的示例 3 即为第二种情况。

timeStepInterval 使用 EsriTimeDelta 类。EsriTimeDelta 类是核心 python datetime.timedelta 的备选选项,针对无法由核心 python timedelta 对象处理的时间间隔使用内部 Esri 时间单位(如月、周等)timeStepInterval 可用于在日期与时间内进行循环。如果希望在一个循环中使用不同的时间间隔,则需创建新的 python timedelta 对象或 EsriTimeDelta 对象(请参阅示例 3)。注意:如果已修改并保存 timeWindowUnits,将会影响 timeStepInterval。

法律声明:

在 10.1 之前的版本,DataFrameTime 类中的 timeStepInterval 属性返回一个 datetime.timedelta 类型的 Python 对象。

要在导出数据框时向图像中嵌入时间戳,请使用时间文本。

ArcGIS 中包含大量关于时态的帮助文档。下面列出了与 DataFrameTime 对象中的方法和属性最为相关的部分内容:

  • 关于修改时间滑块属性
  • 根据数据源使用时间信息
  • 使用时间滑块窗口

属性

属性说明数据类型
currentTime
(读写)

The current date and time for a data frame with time-enabled layers. The same property can be found in the Time Slider Options dialog box in ArcMap.

DateTime
endTime
(读写)

The end date and time for a data frame with time-enabled layers. The same property can be found in the Time Slider Options dialog box in ArcMap.

DateTime
startTime
(读写)

The start date and time for a data frame with time-enabled layers. The same property can be found in the Time Slider Options dialog box in ArcMap.

DateTime
timeStepInterval
(只读)

Returns the time step interval that has been set via the Time Slider Options dialog box in ArcMap. This value is a EsriTimeDelta object and is used to iterate over a period of time (e.g., 2 days, 1 month, and so on).

EsriTimeDelta
timeWindow
(读写)

The time window that controls how many units (e.g., days) of time-enabled data appear prior to and including the current time. For example, if timeWindow is set to 1 and timeWindowUnits is set to weeks, then the time window will be 2 weeks.

Double
timeWindowUnits
(读写)

The units that are used with the TimeStepInterval and the TimeWindow properties. The valid units are:

  • MILLISECONDS
  • SECONDS
  • MINUTES
  • HOURS
  • DAYS
  • WEEKS
  • MONTHS
  • YEARS
  • DECADES
  • CENTURIES
String

方法概述

方法说明
resetTimeExtent ()

将时间范围重新设置为数据框中所有已启用时间的图层的时间窗范围。

方法

resetTimeExtent ()

此函数的作用与在 ArcMap 中单击时间滑块选项 对话框上的最小时间和最大时间按钮的作用相同。

代码实例

DataFrameTime 示例 1

以下脚本使用现有地图文档中发布的时间设置(开始时间、结束时间和时间间隔),以导出一系列的图像。各输出图像均通过时间戳内的解析日期信息给定唯一名称。

import arcpy
import os

mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Traffic Analysis")[0]
df.time.currentTime = df.time.startTime

while df.time.currentTime <= df.time.endTime:
    # An example str(newTime) would be: "2008-12-29 02:19:59"
    # The following line splits the string at the space and takes the first 
    # item in the resulting string.  
    fileName = str(df.time.currentTime).split(" ")[0] + ".png"
    arcpy.mapping.ExportToPNG(mxd, os.path.join(r"C:\Project\Output", fileName), df)
    df.time.currentTime = df.time.currentTime + df.time.timeStepInterval
del mxd
DataFrameTime 示例 2

以下脚本与上述示例 1 相同,但是使用了修改的开始时间、结束时间和间隔,这与地图文档内已启用时间的数据框中所发布的现有设置不同。Python 日期时间模块用于创建时间和时间增量。也可以选用 EsriTimeDelta 类创建时间增量。

import arcpy
import datetime
import os

mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Traffic Analysis")[0]
df.time.currentTime = datetime.datetime(2008, 10, 1)
endTime = datetime.datetime(2008, 10, 31)
interval = datetime.timedelta(days=7)

while df.time.currentTime <= endTime:
    # An example str(newTime) would be: "2008-01-29 02:19:59"
    # The following line splits the string at the space and takes the first 
    # item in the resulting string.  
    fileName = str(df.time.currentTime).split(" ")[0] + ".png"
    arcpy.mapping.ExportToPNG(mxd, os.path.join(r"C:\Project\Output", fileName), df)
    df.time.currentTime = df.time.currentTime + interval
del mxd
DataFrameTime 示例 3

以下脚本表示向不具有时态功能的新数据框添加新的时间图层的情形,因此,并未在地图文档中设置时间滑块属性。此脚本将已启用时间的图层添加到使用 AddLayer 函数的数据框,然后设置与上述脚本类似的相应时间设置。在本示例中,时间间隔使用 EsriTimeDelta 类进行设置。另外,Python 日期时间模块可用于创建时间增量。

import arcpy
import datetime
import os

mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "New Data Frame")[0]
timeLayer = arcpy.mapping.Layer(r"C:\Project\Data\Accidents.lyr")
arcpy.mapping.AddLayer(df, timeLayer, "AUTO_ARRANGE")
df.time.resetTimeExtent()
df.time.timeWindowUnits = "DAYS"
df.time.timeWindow = 7
df.time.currentTime = datetime.datetime(2008, 10, 1)
endTime = datetime.datetime(2008, 10, 31)
interval = arcpy.time.EsriTimeDelta(1, 'weeks')

while df.time.currentTime <= endTime:
    # An example str(newTime) would be: "2008-01-29 02:19:59"
    # The following line splits the string at the space and takes the first
    # item in the resulting string.
    fileName = str(df.time.currentTime).split(" ")[0] + ".png"
    arcpy.mapping.ExportToPNG(mxd, os.path.join(r"C:\Project\Output", fileName))
    df.time.currentTime = df.time.currentTime + interval
del mxd, timeLayer
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明