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
  • マイ プロフィール
  • サイン アウト

Help

  • ホーム
  • はじめに
  • マップ
  • 解析
  • データ管理
  • ツール
  • その他...

ListBookmarks

  • サマリ
  • 説明
  • 構文
  • コードのサンプル

サマリ

Returns a Python list of named tuples that provide access to each spatial bookmark's name and extent.

説明

ListBookmarks always returns a Python list of named tuples. Each tuple provides the bookmark's name as a string and the bookmark's extent as an Extent object. In order to return a specific tuple, an index value must be used on the list (for example, bkmk = arcpy.mapping.ListBookmarks(mxd)[0]). For loops on a list provide an easy mechanism to iterate through each tuple in the list (for example, for bkmk in arcpy.mapping.ListBookmarks(mxd):).

Wildcards are used on the name property and are not case sensitive. A wildcard string of "so*" will return a spatial bookmark with the name South East. Wildcards can be skipped in the scripting syntax by passing an empty string (""), an asterisk (*), or entering wildcard=None, or nothing at all if it is the last optional parameter in the syntax.

Avoid having spatial bookmarks in a single data frame that have the same name because the name property is really the only practical way of identifying a spatial extent. Bookmarks can have the same name if they are in different data frames.

構文

ListBookmarks (map_document, {wildcard}, {data_frame})
パラメータ説明データ タイプ
map_document

A variable that references a MapDocument object.

MapDocument
wildcard

A combination of asterisks (*) and characters can be used to help limit the results. It is used to filter spatial bookmark names.

(デフォルト値は次のとおりです None)

String
data_frame

A variable that references a DataFrame object. This is used to find a spatial bookmark associated with a specific data frame.

(デフォルト値は次のとおりです None)

DataFrame

戻り値

データ タイプ説明
List

A Python list of named tuples.

  • extent —A GP Extent object
  • name —A string that represents the name of a spatial bookmark

コードのサンプル

ListBookmarks example 1

This script will print the name of each spatial bookmark in a data frame named Transportation. The wildcard parameter is skipped using a blank string.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
for bkmk in arcpy.mapping.ListBookmarks(mxd, "", df):
    print bkmk.name
del mxd
ListBookmarks example 2

Similar to example 1, the following script will loop through each bookmark in the Transportation data frame, set the data frame extent, and export the data frame to a JPEG file.

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
for bkmk in arcpy.mapping.ListBookmarks(mxd, data_frame=df):
    df.extent = bkmk.extent
    outFile = r"C:\Project\Output\\" + bkmk.name + ".jpg"
    arcpy.mapping.ExportToJPEG(mxd, outFile, df)
del mxd
ListBookmarks example 3

This sample will convert each bookmark in a map document to a feature. The resulting feature class can be used for a variety of workflows, including use as a Data Driven Pages index layer for creating map books.

import arcpy, os

# The map with the bookmarks
mxd = arcpy.mapping.MapDocument(r"C:\Project\Counties.mxd")

# The output feature class to be created -
# This feature class will store the bookmarks as features
outFC = r'C:\Project\Counties.gdb\Bookmarks'

# A template feature class that contains the attribute schema
# Including a "Name" field to store the bookmark name
template = r'C:\Project\Counties.gdb\Template'

if arcpy.Exists(outFC):
    arcpy.Delete_management(outFC)
arcpy.CreateFeatureclass_management(os.path.dirname(outFC),
                                    os.path.basename(outFC), 
                                    "POLYGON", template, 
                                    spatial_reference=template)

cur = arcpy.da.InsertCursor(outFC, ["SHAPE@", "Name"])
array = arcpy.Array()
for bkmk in arcpy.mapping.ListBookmarks(mxd):
    array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin))
    array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMax))
    array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMax))
    array.add(arcpy.Point(bkmk.extent.XMax, bkmk.extent.YMin))
    # To close the polygon, add the first point again
    array.add(arcpy.Point(bkmk.extent.XMin, bkmk.extent.YMin))
    cur.insertRow([arcpy.Polygon(array), bkmk.name])
    array.removeAll()
このトピックへのフィードバック

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. | プライバシー | リーガル