-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapping.py
1915 lines (1527 loc) · 91.8 KB
/
mapping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
#COPYRIGHT 2012 ESRI
#
#TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
#Unpublished material - all rights reserved under the
#Copyright Laws of the United States.
#
#For additional information, contact:
#Environmental Systems Research Institute, Inc.
#Attn: Contracts Dept
#380 New York Street
#Redlands, California, USA 92373
#
#email: contracts@esri.com
from _mapping import MapDocument, Layer, TableView, constants
from arcpy.arcobjects import mixins
from arcpy.arcobjects._base import _BaseArcObject, passthrough_attr
from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
from arcpy.geoprocessing._base import gp_fixargs
from arcpy.utils import logcall, ArgAdaptor
import logging
import os
@constants.maskargs
def AddLayer(data_frame, add_layer, add_position='AUTO_ARRANGE'):
"""AddLayer(data_frame, add_layer, {add_position})
Provides the ability to add a layer to a data frame within a map document (
.mxd ) using simple placement options.
data_frame(DataFrame):
A reference to a DataFrame object within a map document.
add_layer(Layer):
A reference to a Layer object representing the layer to be added. This
reference can point to a layer file on disk or a layer within a map
document.
add_position{String}:
A constant that determines the placement of the added layer within a data
frame.
* AUTO_ARRANGE: Automatically places the layer similar to how the Add Data
button works in ArcMap
* BOTTOM: Places the layer at the bottom of the data frame
* TOP: Places the layer at the top of the data frame"""
from ._mapping import DataFrame, Layer
assert isinstance(data_frame, DataFrame)
assert isinstance(add_layer, Layer)
my_copy = add_layer._arc_object.copy()
if add_position.upper() == 'BOTTOM':
lyrlist = data_frame._arc_object.layers
data_frame._arc_object.InsertLayer(None, my_copy, len(lyrlist))
elif add_position.upper() == 'TOP':
data_frame._arc_object.InsertLayer(None, my_copy, 0)
elif add_position.upper() == 'AUTO_ARRANGE':
data_frame._arc_object.InsertLayer(None, my_copy)
@constants.maskargs
def AddLayerToGroup(data_frame, target_group_layer, add_layer, add_position='AUTO_ARRANGE'):
"""AddLayerToGroup(data_frame, target_group_layer, add_layer, {add_position})
Provides the ability to add a layer to a group layer within a map document
( .mxd ) using simple placement options.
data_frame(DataFrame):
A reference to a DataFrame object that contains the group layer to which
the new layer will be added.
target_group_layer(Layer):
A Layer object representing the group layer to which the new layer will be
added. It must be a group layer.
add_layer(Layer):
A reference to a Layer object representing the layer to be added. This
reference can point to a layer file on disk or a layer in a map document.
add_position{String}:
A constant that determines the placement of the added layer within a data
frame.
* AUTO_ARRANGE: Automatically places the layer similar to how the Add Data
button works in ArcMap
* BOTTOM: Places the layer at the bottom of the data frame
* TOP: Places the layer at the top of the data frame"""
from ._mapping import DataFrame, Layer
assert isinstance(data_frame, DataFrame)
assert isinstance(target_group_layer, Layer) and target_group_layer._arc_object.isGroupLayer
assert isinstance(add_layer, Layer)
my_copy = add_layer._arc_object.copy()
if add_position.upper() == 'BOTTOM':
lyrlist = target_group_layer._arc_object.layers
data_frame._arc_object.InsertLayer(target_group_layer._arc_object, my_copy, len(lyrlist)+1)
elif add_position.upper() == 'TOP':
lyrlist = target_group_layer._arc_object.layers
data_frame._arc_object.InsertLayer(target_group_layer._arc_object, my_copy, 0)
elif add_position.upper() == 'AUTO_ARRANGE':
data_frame._arc_object.InsertLayer(target_group_layer._arc_object, my_copy)
@constants.maskargs
def AddTableView(data_frame, add_table):
"""AddTableView(data_frame, add_table)
Provides the ability to add a table to a data frame within a map document (
.mxd ).
data_frame(DataFrame):
A reference to a DataFrame object within a map document.
add_table(TableView):
A reference to a TableView object representing the table to be added. This
reference can point to a table within an existing map document or it can
reference a table in a workspace via the TableView function."""
from ._mapping import DataFrame, TableView
assert isinstance(data_frame, DataFrame)
assert isinstance(add_table, TableView)
data_frame._arc_object.InsertTableView(add_table._arc_object)
@constants.maskargs
def AnalyzeForMSD(map_document):
"""AnalyzeForMSD(map_document)
Starting at ArcGIS 10.1 for Server , Map Server Definition ( .msd ) files
have been replaced with Service Definition Draft ( .sddraft ) and Service
Definition ( .sd ) files. Please use the AnalyzeForSD function instead.
Analyzes map documents ( .mxd ) to determine sources for potential
suitability and performance issues when converting a map to a map service
definition ( .msd ) file.
map_document(MapDocument):
A variable that references a MapDocument object."""
result = mixins.MapDocumentMixin(map_document).analyzeForMSD()
return result
def AnalyzeForSD(sddraft):
"""AnalyzeForSD(sddraft)
Analyzes Service Definition Draft ( .sddraft ) files to determine
suitability and sources of potential performance issues before converting
a Service Definition Draft file to a Service Definition ( .sd ) file.
sddraft(String):
A string that represents the path and file name for the Service Definition
Draft ( .sddraft ) file."""
import arcgisscripting
return convertArcObjectToPythonObject(arcgisscripting._analyzeForSD(*gp_fixargs([sddraft], True)))
@constants.maskargs
def ConvertToMSD(map_document, out_msd, data_frame='USE_ACTIVE_VIEW', msd_anti_aliasing=0, msd_text_anti_aliasing=0):
"""ConvertToMSD(map_document, out_msd, {data_frame}, {msd_anti_aliasing}, {msd_text_anti_aliasing})
Starting at ArcGIS 10.1 for Server , Map Server Definition ( .msd ) files
have been replaced with Service Definition Draft ( .sddraft ) and Service
Definition ( .sd ) files. Please use the CreateMapSDDraft function instead.
Converts a map to a map service definition ( .msd ) file.
map_document(MapDocument):
A variable that references a MapDocument object.
out_msd(String):
A string that represents the path and file name for the output MSD file.
data_frame{DataFrame}:
A variable that references a DataFrame object. If more than one data frame
exists, it is important to specify which data frame will be the active data
frame for the published service. The default value is the active data
frame.
msd_anti_aliasing{String}:
A string that sets antialiasing for nontext items within the saved MSD.
* NONE: No antialiasing is performed.
* FASTEST: Minimal antialiasing is performed, optimized for speed.
* FAST: Some antialiasing is performed, optimized for speed with better
quality than FASTEST.
* NORMAL: A good balance of speed and quality.
* BEST: The best quality antialiasing. This option takes the longest to
render.
msd_text_anti_aliasing{String}:
A string that sets antialiasing for text items within the saved MSD.
* FORCE: Text is always drawn with antialiasing, regardless of the
individual font's parameters.
* NORMAL: Antialiasing is performed as determined by the font. Each
individual font has parameters created within it by the font author that
defines which sizes the font should draw with antialiasing.
* NONE: No antialiasing is performed."""
result = mixins.MapDocumentMixin(map_document).convertToMSD(out_msd, data_frame, msd_anti_aliasing, msd_text_anti_aliasing)
return result
def ConvertWebMapToMapDocument(webmap_json, template_mxd=None, notes_gdb=None, extra_conversion_options=None):
"""ConvertWebMapToMapDocument(webmap_json, {template_mxd}, {notes_gdb}, {extra_conversion_options})
Converts a web map (in JSON format) that you intend to print or export to a
map document.
The map document can be further modified before finally being printed or
exported.
webmap_json(String):
The web map for printing in JavaScript Object Notation (JSON).
See the ExportWebMap JSON specification for more information. The ArcGIS
Web APIs (JavaScript, Flex, and Silverlight) allow developers to easily get
this JSON string from the web application.
template_mxd{String}:
A string representing the path and file name to a map document (. mxd ) to
use as the template for the page layout. The contents of the web map will
be inserted into the data frame that was active at the time the
template_mxd was saved. Layers in the template_mxd file's active data frame
(and all other data frames) will be preserved in the output mapDocument .
notes_gdb{String}:
A string representing the path to a new or existing file geodatabase or an
existing enterprise geodatabase connection where graphic features should be
written. This parameter should only be used if graphic features from the
web map JSON need to be preserved permanently. In most cases, this
parameter is not required, as a temporary in-memory workspace will be used
to store graphic features. This parameter allows you to save graphic
features to persistent storage, which is essential if you plan to use the
map document for operations that require saving or loading from disk (for
example, packaging or consolidating). The path must end with a .gdb or .sde
extension.
extra_conversion_options{Dictionary}:
A dictionary of credentials for secured services. This parameter is
required if the services in the web map JSON require a user name and
password to view. Keys accepted in the dictionary are as follows:
SERVER_CONNECTION_FILE WMS_CONNECTION_FILE WMTS_CONNECTION_FILE
An example of key value pairs is as follows: credentials =
{"SERVER_CONNECTION_FILE":r"Z:\ArcGIS2 on MyServer (user).ags",
"WMS_CONNECTION_FILE":r"Z:\USA on MyServer.wms"}
result = arcpy.mapping.ConvertWebMapToMapDocument(json,
extra_conversion_options=credentials)
Lists of connection files can be used when there are multiple secured
services: agsConnections = [r"Z:\ArcGIS on SecuredServerA (user).ags",
r"Z:\ArcGIS on SecuredServerB (user).ags"]
credentials = {"SERVER_CONNECTION_FILE":agsConnections,
"WMS_CONNECTION_FILE":r"Z:\USA on MyServer.wms"}
result = arcpy.mapping.ConvertWebMapToMapDocument(json,
extra_conversion_options=credentials)"""
from .arcobjects.mixins import webmap_tuple
import arcgisscripting
return webmap_tuple(*convertArcObjectToPythonObject(arcgisscripting._convertWebMapToMapDocument(webmap_json, template_mxd, notes_gdb, extra_conversion_options)))
@constants.maskargs
def CreateGISServerConnectionFile(connection_type, out_folder_path, out_name, server_url, server_type=None, use_arcgis_desktop_staging_folder=None, staging_folder_path=None, username=None, password=None, save_username_password=None):
"""CreateGISServerConnectionFile(connection_type, out_folder_path, out_name, server_url, server_type, {use_arcgis_desktop_staging_folder}, {staging_folder_path}, {username}, {password}, {save_username_password})
This function creates a connection file that can be used to connect to a
GIS Server.
connection_type(String):
A string that represents the connection type.
You can create a connection to use, publish, or administer GIS Services.
* USE_GIS_SERVICES: Use GIS Services.
* PUBLISH_GIS_SERVICES: Publish GIS Services.
* ADMINISTER_GIS_SERVICES: Administer GIS Services.
out_folder_path(String):
The folder path where the .ags file will be stored. Entering a value of GIS
Servers will put the .ags file in the GIS Servers node in the Catalog
window.
out_name(String):
The name of the .ags file. The output file extension must end with .ags.
server_url(String):
A string that represents the URL to the server.
server_type(String):
A string that represents the type of server.
* ARCGIS_SERVER: ArcGIS for Server server type
* SPATIAL_DATA_SERVER: Spatial Data Server server type
If you are using SPATIAL_DATA_SERVER server_type , starting at ArcGIS
10.2.1 for Desktop , only USE_GIS_SERVICES connection_type is supported.
Any connection_type is supported for ARCGIS_SERVER server_type .
use_arcgis_desktop_staging_folder{Boolean}:
A Boolean that determines whether to use ArcGIS for Desktop 's staging
folder. If set to true, you do not have to enter a staging_folder_path as
ArcGIS for Desktop 's staging folder will be used. This parameter is only
used if the connection_type is PUBLISH_GIS_SERVICES or
ADMINISTER_GIS_SERVICES .
staging_folder_path{String}:
A string that represents the staging folder path. If you will be using
this connection to create and save service definitions, you can choose
where the service definition files will be staged on disk. By default, they
are staged in a folder on your local machine. If this parameter is set to
None, ArcGIS for Desktop 's staging folder will be used. This parameter is
only used if the connection_type is PUBLISH_GIS_SERVICES or
ADMINISTER_GIS_SERVICES .
username{String}:
A string that represents the user name to the GIS server.
password{String}:
A string that represents the password to the GIS server.
save_username_password{Boolean}:
A Boolean that represents whether the user name and password to the GIS
Server will be saved in the connection file.
* SAVE_USERNAME: Save the user name and password in the connection file.
* DO_NOT_SAVE_USERNAME: Do not save the user name and password in the
connection file."""
import arcgisscripting
return convertArcObjectToPythonObject(arcgisscripting._createGISServerConnectionFile(*gp_fixargs([connection_type, out_folder_path, out_name, server_url, server_type, use_arcgis_desktop_staging_folder, staging_folder_path, username, password, save_username_password], True, False)))
@constants.maskargs
def CreateMapSDDraft(map_document, out_sddraft, service_name=None, server_type='ARCGIS_SERVER', connection_file_path=None, copy_data_to_server=False, folder_name=None, summary=None, tags=None):
"""CreateMapSDDraft(map_document, out_sddraft, service_name, {server_type}, {connection_file_path}, {copy_data_to_server}, {folder_name}, {summary}, {tags})
Converts Map Document ( .mxd ) files to Service Definition Draft ( .sddraft
) files.
map_document(MapDocument):
A variable that references a MapDocument object. The data frame that was
active at the time the map_document was saved will be published.
out_sddraft(String):
A string that represents the path and file name for the output Service
Definition Draft ( .sddraft ) file.
service_name(String):
A string that represents the name of the service. This is the name people
will see and use to identify the service. The name can only contain
alphanumeric characters and underscores. No spaces or special characters
are allowed. The name cannot be more than 120 characters in length.
server_type{String}:
A string representing the server type.
If a connection_file_path parameter is not supplied, then a server_type
must be provided. If a connection_file_path parameter is supplied, then the
server_type is taken from the connection file. In this case, you can choose
FROM_CONNECTION_FILE or skip the parameter entirely.
* ARCGIS_SERVER: ArcGIS for Server server type
* FROM_CONNECTION_FILE: Get the server_type as specified in the
connection_file_path parameter
* MY_HOSTED_SERVICES: My Hosted Services server type for ArcGIS Online or
Portal for ArcGIS
Starting at ArcGIS 10.2.1 for Desktop , SPATIAL_DATA_SERVER is not a
supported server_type .
connection_file_path{String}:
A string that represents the path and file name to the ArcGIS for Server
connection file ( .ags ).
When the server_type is set to MY_HOSTED_SERVICES , connection_file_path is
not required.
copy_data_to_server{Boolean}:
A Boolean that indicates whether the data referenced in the map document
will be copied to the server or not.
The copy_data_to_server parameter is only used if the server_type is
ARCGIS_SERVER and the connection_file_path isn't specified. If the
connection_file_path is specified, then the server's registered data stores
are used. For example, if the data in the map_document is registered with
the server, then copy_data_to_server will always be False . Conversely, if
the data in the map_document is not registered with the server, then
copy_data_to_server will always be True .
When the server_type is set to MY_HOSTED_SERVICES , copy_data_to_server
will always be True . My Hosted Maps services always copy data to the
server.
folder_name{String}:
A string that represents a folder name to which you want to publish the
service definition. If the folder does not currently exist, it will be
created. The default folder is the server root level.
summary{String}:
A string that represents the Item Description Summary.
By default, the Summary from the ArcMap Map Properties dialog box or
Catalog window Item Description dialog box for the map_document will be
used. Use this parameter to override the user interface summary, or to
provide a summary if one does not exist. The summary provided here will not
be persisted in the map document.
tags{String}:
A string that represents the Item Description Tags.
By default, the Tags from the ArcMap Map Properties dialog box or Catalog
window Item Description dialog box for the map_document will be used. Use
this parameter to override the user interface tags, or to provide tags if
they do not exist. The tags provided here will not be persisted in the map
document."""
import arcgisscripting
return convertArcObjectToPythonObject(arcgisscripting._createMapSDDraft(*gp_fixargs([map_document, out_sddraft, service_name, server_type, connection_file_path, copy_data_to_server, folder_name, summary, tags], True, False)))
def DeleteMapService(connection_url_or_name, server, service_name, folder_name='', connection_username=None, connection_password=None, connection_domain=None):
"""DeleteMapService(connection_url_or_name, server, service_name, {folder_name}, {connection_username}, {connection_password}, {connection_domain})
This method has been deprecated starting at ArcGIS 10.1 for Server and
ArcGIS 10.1 for Desktop and will return a runtime error. Please consult
the ArcGIS documentation for the usage of the new ArcGIS for Server
Administrator API . Deletes a map service from a designated ArcGIS for
Server .
connection_url_or_name(String):
A string that represents the URL of the ArcGIS for Server for which you
want to delete a service.
server(String):
A string that represents the ArcGIS for Server host name.
service_name(String):
A string that represents the name of the service. This is the name people
will see and use to identify the service. The name can only contain
alphanumeric characters and underscores. No spaces or special characters
are allowed. The name cannot be more than 120 characters in length.
folder_name{String}:
A string that represents a folder name.
connection_username{String}:
A string that represents a user name used to connect to ArcGIS for Server .
This variable is only necessary when connecting to a UNIX/Linux ArcGIS for
Server .
connection_password{String}:
A string that represents a password used to connect to the ArcGIS for
Server . This variable is only necessary when connecting to a UNIX/Linux
ArcGIS for Server .
connection_domain{String}:
A string that represents a domain name used to connect to the ArcGIS for
Server . This variable is only necessary when connecting to a UNIX/Linux
ArcGIS for Server ."""
from arcpy import GetIDMessage
raise Exception(GetIDMessage(88014, 'This method has been deprecated. Please consult the help for the usage of the new ArcGIS Server APIs.'))
@constants.maskargs
def ExportReport(report_source, report_layout_file, output_file, dataset_option='USE_RLF', report_title=None, starting_page_number=1, page_range=None, report_definition_query=None, extent=None, field_map=None):
"""ExportReport(report_source, report_layout_file, output_file, {dataset_option}, {report_title}, {starting_page_number}, {page_range}, {report_definition_query}, {extent}, {field_map})
Exports a formatted, tabular report using data from layers or stand-alone
tables in a map document along with the report template information that is
provided in a report layout file ( .rlf ).
report_source(Object):
A reference to a Layer or TableView object.
report_layout_file(String):
A string that represents the path and file name of the report layout file
( .rlf ).
output_file(String):
A string that represents the path and file name of the output file. The
specified file extension controls the output format. The following
extensions/formats are supported: .htm, .html, .pdf, .rtf, .tif, .tiff,
.txt, and .xls .
dataset_option{String}:
A keyword that specifies which dataset rows will be processed in the output
report. This value will override the Dataset Options value stored in the
report layout file which is found in the Report Properties dialog box. If
the dataset_option parameter is not set, it will default to the value
stored in the report layout file. If the dataset_option is set to
DEFINITION_QUERY , then a valid string needs to be provided for the
report_definition_query parameter. If the dataset_option is set to EXTENT
, then a valid Extent object needs to be provided for the extent parameter.
Because the dataset_option keyword controls which additional parameter to
use, only one of these parameters can be set at a time, just like in the
user interface.
* ALL: Override the report layout file dataset option and process all data
source records.
* DEFINITION_QUERY: Override the report layout file dataset option and
provide a new or updated definition query.
* EXTENT: Override the report layout file dataset option and provide a new
or updated extent.
* SELECTED: Override the report layout file dataset option and process
only the selected records.
* USE_RLF: Use the settings saved in the report layout file.
report_title{String}:
A string that represents the report's title which appears in the report
layout file header section.
starting_page_number{Long}:
A number that represents the printed page number for the first page of the
output report. This value is useful for offsetting page numbers for
reports that get appended to the end of existing documents.
page_range{String}:
A string that identifies the report pages to be exported to file (for
example, 1, 3, 5?12 ).
report_definition_query{String}:
A string that represents a valid definition query that controls which rows
will be exported to the output report. This parameter can only be set if
the dataset_option parameter is set to DEFINITION_QUERY .This value will
overwrite any settings stored in the report layout file. If the
report_source layer or table has an existing definition query, then the
report_definition_query will be applied to the existing subset of records.
extent{Extent}:
A geoprocessing Extent object. This parameter can only be set if the
dataset_option parameter is set to EXTENT . When an extent object is passed
into this parameter, the rows will be based on those features that
intersect the extent.
field_map{Dictionary}:
This parameter allows you to use a report layout file with a data source
that has similar data types but different field names. A dictionary of
mapped field names is used to remap the fields used in the report layout
file with the new fields in the data source. The following shows an example
of the field_map dictionary structure:
field_map={'rlf_field1':'data_source_field1',
'rlf_field2':'data_source_field2'}"""
from ._mapping import MapDocument, TableView, Layer
from .utils import getstartingpage
from .geoprocessing._base import gp_fixargs
assert isinstance(report_source, (MapDocument, TableView, Layer)), str(type(report_source))
if starting_page_number != 1 and ',' in (page_range or ''):
raise ValueError(page_range)
if page_range and starting_page_number != 1:
min_page = getstartingpage(page_range)
starting_page_number -= (min_page - 1)
if isinstance(dataset_option, basestring) and dataset_option.upper() == 'USE_RLF':
dataset_option = 2
return report_source._arc_object.ExportReport(*gp_fixargs((report_layout_file, output_file, dataset_option, report_title, starting_page_number, page_range, report_definition_query, extent, field_map), True))
@constants.maskargs
def ExportToAI(map_document, out_ai, data_frame='PAGE_LAYOUT', df_export_width=640, df_export_height=480, resolution=300, image_quality='BEST', colorspace='RGB', picture_symbol='RASTERIZE_BITMAP', convert_markers=False):
"""ExportToAI(map_document, out_ai, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {image_quality}, {colorspace}, {picture_symbol}, {convert_markers})
Exports the page layout or data frame of a map document ( .mxd ) to Adobe
Illustrator (AI) format.
map_document(MapDocument):
A variable that references a MapDocument object.
out_ai(String):
A string that represents the path and file name for the output export file.
data_frame{Object}:
A variable that references a DataFrame object. Use the string/constant
"PAGE_LAYOUT" to export the map document's page layout instead of an
individual data frame.
df_export_width{Integer}:
A number that defines the width of the export image in pixels for a data
frame export. df_export_width is only used when exporting a data frame.
Exporting a page layout uses the map document page width instead of
df_export_width .
df_export_height{Integer}:
A number that defines the height of the export image in pixels for a data
frame export. df_export_height is only used when exporting a data frame.
Exporting a page layout uses the map document page height instead of
df_export_height .
resolution{Integer}:
A number that defines the resolution of the export file in dots per inch
(DPI).
image_quality{String}:
A string that defines output image quality, the draw resolution of map
layers that draw as rasters.
* BEST: An output image quality resample ratio of 1.
* BETTER: An output image quality resample ratio of 2.
* NORMAL: An output image quality resample ratio of 3.
* FASTER: An output image quality resample ratio of 4.
* FASTEST: An output image quality resample ratio of 5.
colorspace{String}:
A string that defines which color space will be written to the export file.
* CMYK: Cyan, Magenta,Yellow, and blacK color model.
* RGB: Red, Green, and Blue color model.
picture_symbol{String}:
A string that defines whether picture markers and picture fills will be
converted to vector or rasterized on output.
* RASTERIZE_BITMAP: Rasterize layers with bitmap markers/fills.
* RASTERIZE_PICTURE: Rasterize layers with any picture marker/fill.
* VECTORIZE_BITMAP: Vectorize layers with bitmap markers/fills.
convert_markers{Boolean}:
A Boolean that controls the coversion of character-based marker symbols to
polygons. This allows the symbols to appear correctly if the symbol font is
not available or cannot be embedded. However, setting this parameter to
True disables font embedding for all character-based marker symbols, which
can result in a change in their appearance."""
from .geoprocessing._base import gp_fixargs
from ._mapping import MapDocument, DataFrame
assert isinstance(map_document, MapDocument)
mapdoc = mixins.MapDocumentMixin(map_document)
if data_frame:
assert isinstance(data_frame, DataFrame) or (isinstance(data_frame, basestring) and data_frame.lower() == 'page_layout')
if isinstance(data_frame, basestring):
data_frame = None
layout = data_frame._arc_object if data_frame else mapdoc
args = gp_fixargs((out_ai, df_export_width, df_export_height, resolution, image_quality, colorspace, picture_symbol, convert_markers))
layout.exportToAI(*args)
@constants.maskargs
def ExportToBMP(map_document, out_bmp, data_frame='PAGE_LAYOUT', df_export_width=640, df_export_height=480, resolution=96, world_file=None, color_mode='24-BIT_TRUE_COLOR', rle_compression='NONE'):
"""ExportToBMP(map_document, out_bmp, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {rle_compression})
Exports the page layout or data frame of a map document ( .mxd ) to the
Microsoft Windows Bitmap (BMP) format.
map_document(MapDocument):
A variable that references a MapDocument object.
out_bmp(String):
A string that represents the path and file name for the output export file.
data_frame{Object}:
A variable that references a DataFrame object. Use the string/constant
"PAGE_LAYOUT" to export the map document's page layout instead of an
individual data frame.
df_export_width{Integer}:
A number that defines the width of the export image in pixels for a data
frame export. df_export_width is only used when exporting a data frame.
Exporting a page layout uses the map document page width instead of
df_export_width .
df_export_height{Integer}:
A number that defines the height of the export image in pixels for a data
frame export. df_export_height is only used when exporting a data frame.
Exporting a page layout uses the map document page height instead of
df_export_height .
resolution{Integer}:
A number that defines the resolution of the export file in dots per inch
(DPI).
world_file{Boolean}:
If set to True , a georeferenced world file is created. The file contains
pixel scale information and real-world coordinate information.
color_mode{String}:
This value specifies the number of bits used to describe color.
* 24-BIT_TRUE_COLOR: 24-bit true color.
* 8-BIT_PALETTE: 8-bit palette.
* 8-BIT_GRAYSCALE: 8-bit grayscale.
* 1-BIT_MONOCHROME_MASK: 1-bit monochrome mask.
* 1-BIT_MONOCHROME_THRESHOLD: 1-bit monochrome threshold.
rle_compression{String}:
This value represents a compression scheme.
* NONE: Compression is not applied.
* RLE: Run-length encoded compression."""
from .geoprocessing._base import gp_fixargs
from ._mapping import MapDocument, DataFrame
assert isinstance(map_document, MapDocument)
mapdoc = mixins.MapDocumentMixin(map_document)
if data_frame:
assert isinstance(data_frame, DataFrame) or (isinstance(data_frame, basestring) and data_frame.lower() == 'page_layout')
if isinstance(data_frame, basestring):
data_frame = None
layout = data_frame._arc_object if data_frame else mapdoc
args = gp_fixargs((out_bmp, df_export_width, df_export_height, resolution, world_file, color_mode, rle_compression))
layout.exportToBMP(*args)
@constants.maskargs
def ExportToEMF(map_document, out_emf, data_frame='PAGE_LAYOUT', df_export_width=640, df_export_height=480, resolution=300, image_quality='BEST', description='', picture_symbol='RASTERIZE_BITMAP', convert_markers=False):
"""ExportToEMF(map_document, out_emf, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {image_quality}, {description}, {picture_symbol}, {convert_markers})
Exports the page layout or data frame of a map document ( .mxd ) to the
Enhanced Metafile (EMF) format.
map_document(MapDocument):
A variable that references a MapDocument object.
out_emf(String):
A string that represents the path and file name for the output export file.
data_frame{Object}:
A variable that references a DataFrame object. Use the string/constant
"PAGE_LAYOUT" to export the map document's page layout instead of an
individual data frame.
df_export_width{Integer}:
A number that defines the width of the export image in pixels for a data
frame export. df_export_width is only used when exporting a data frame.
Exporting a page layout uses the map document page width instead of
df_export_width .
df_export_height{Integer}:
A number that defines the height of the export image in pixels for a data
frame export. df_export_height is only used when exporting a data frame.
Exporting a page layout uses the map document page height instead of
df_export_height .
resolution{Integer}:
A number that defines the resolution of the export file in dots per inch
(DPI).
image_quality{String}:
A string that defines output image quality, the draw resolution of map
layers that draw as rasters.
* BEST: An output image quality resample ratio of 1.
* BETTER: An output image quality resample ratio of 2.
* NORMAL: An output image quality resample ratio of 3.
* FASTER: An output image quality resample ratio of 4.
* FASTEST: An output image quality resample ratio of 5.
description{String}:
A string that assigns a description to the output file.
picture_symbol{String}:
A string that defines whether picture markers and picture fills will be
converted to vector or rasterized on output.
* RASTERIZE_BITMAP: Rasterize layers with bitmap markers/fills.
* RASTERIZE_PICTURE: Rasterize layers with any picture marker/fill.
* VECTORIZE_BITMAP: Vectorize layers with bitmap markers/fills.
convert_markers{Boolean}:
A Boolean that controls the coversion of character-based marker symbols to
polygons. This allows the symbols to appear correctly if the symbol font is
not available or cannot be embedded. However, setting this parameter to
True disables font embedding for all character-based marker symbols, which
can result in a change in their appearance."""
from .geoprocessing._base import gp_fixargs
from ._mapping import MapDocument, DataFrame
assert isinstance(map_document, MapDocument)
mapdoc = mixins.MapDocumentMixin(map_document)
if data_frame:
assert isinstance(data_frame, DataFrame) or (isinstance(data_frame, basestring) and data_frame.lower() == 'page_layout')
if isinstance(data_frame, basestring):
data_frame = None
layout = data_frame._arc_object if data_frame else mapdoc
args = gp_fixargs((out_emf, df_export_width, df_export_height, resolution, image_quality, description, picture_symbol, convert_markers))
layout.exportToEMF(*args)
@constants.maskargs
def ExportToEPS(map_document, out_eps, data_frame='PAGE_LAYOUT', df_export_width=640, df_export_height=480, resolution=300, image_quality='BEST', colorspace='RGB', ps_lang_level=3, image_compression='ADAPTIVE', picture_symbol='RASTERIZE_BITMAP', convert_markers=False, embed_fonts=False, jpeg_compression_quality=80):
"""ExportToEPS(map_document, out_eps, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {image_quality}, {colorspace}, {ps_lang_level}, {image_compression}, {picture_symbol}, {convert_markers}, {embed_fonts}, {jpeg_compression_quality})
Exports the page layout or data frame of a map document ( .mxd ) to an
Encapsulated Postscript (EPS) format.
map_document(MapDocument):
A variable that references a MapDocument object.
out_eps(String):
A string that represents the path and file name for the output export file.
data_frame{Object}:
A variable that references a DataFrame object. Use the string/constant
"PAGE_LAYOUT" to export the map document's page layout instead of an
individual data frame.
df_export_width{Integer}:
A number that defines the width of the export image in pixels for a data
frame export. df_export_width is only used when exporting a data frame.
Exporting a page layout uses the map document page width instead of
df_export_width .
df_export_height{Integer}:
A number that defines the height of the export image in pixels for a data
frame export. df_export_height is only used when exporting a data frame.
Exporting a page layout uses the map document page height instead of
df_export_height .
resolution{Integer}:
A number that defines the resolution of the export file in dots per inch
(DPI).
image_quality{String}:
A string that defines output image quality, the draw resolution of map
layers that draw as rasters.
* BEST: An output image quality resample ratio of 1.
* BETTER: An output image quality resample ratio of 2.
* NORMAL: An output image quality resample ratio of 3.
* FASTER: An output image quality resample ratio of 4.
* FASTEST: An output image quality resample ratio of 5.
colorspace{String}:
A string that defines the colorspace of the export file.
* CMYK: Cyan, Magenta,Yellow, and blacK color model.
* RGB: Red, Green, and Blue color model.
ps_lang_level{Integer}:
A number that represents the PostScript Language level. Level 3 is the most
recent release, but some older PostScript interpreters may not be able to
read files created using this version. Valid levels are 2 and 3.
image_compression{String}:
A string that defines the compression scheme used to compress image or
raster data in the output file.
* ADAPTIVE: Automatically selects the best compression type for each
image on the page. JPEG will be used for large images with many unique
colors. DEFLATE will be used for all other images.
* JPEG: A lossy data compression.
* DEFLATE: A lossless data compression.
* LZW: Lempel-Ziv-Welch, a lossless data compression.
* NONE: Compression is not applied.
* RLE: Run-length encoded compression.
picture_symbol{String}:
A string that defines whether picture markers and picture fills will be
converted to vector or rasterized on output.
* RASTERIZE_BITMAP: Rasterize layers with bitmap markers/fills.
* RASTERIZE_PICTURE: Rasterize layers with any picture marker/fill.
* VECTORIZE_BITMAP: Vectorize layers with bitmap markers/fills.
convert_markers{Boolean}:
A Boolean that controls the coversion of character-based marker symbols to
polygons. This allows the symbols to appear correctly if the symbol font is
not available or cannot be embedded. However, setting this parameter to
True disables font embedding for all character-based marker symbols, which
can result in a change in their appearance.
embed_fonts{Boolean}:
A Boolean that controls the embedding of fonts in export files. Font
embedding allows text and character markers to be displayed correctly when
the document is viewed on a computer that does not have necessary fonts
installed.
jpeg_compression_quality{Integer}:
A number that controls compression quality value when image_compression is
set to ADAPTIVE or JPEG. The valid range is 1 to 100. A
jpeg_compression_quality of 100 provides the best quality images but
creates large export files. The recommended range is between 70 and 90."""
from .geoprocessing._base import gp_fixargs
from ._mapping import MapDocument, DataFrame
assert isinstance(map_document, MapDocument)
mapdoc = mixins.MapDocumentMixin(map_document)
if data_frame:
assert isinstance(data_frame, DataFrame) or (isinstance(data_frame, basestring) and data_frame.lower() == 'page_layout')
if isinstance(data_frame, basestring):
data_frame = None
layout = data_frame._arc_object if data_frame else mapdoc
args = gp_fixargs((out_eps, df_export_width, df_export_height, resolution, image_quality, colorspace, ps_lang_level, image_compression, picture_symbol, convert_markers, embed_fonts, jpeg_compression_quality))
layout.exportToEPS(*args)
@constants.maskargs
def ExportToGIF(map_document, out_gif, data_frame='PAGE_LAYOUT', df_export_width=640, df_export_height=480, resolution=96, world_file=None, color_mode='8-BIT_PALETTE', gif_compression='NONE', background_color='255, 255, 255', transparent_color=None, interlaced=False):
"""ExportToGIF(map_document, out_gif, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {gif_compression}, {background_color}, {transparent_color}, {interlaced})
Exports the page layout or data frame of a map document ( .mxd ) to the
Graphic Interchange (GIF) format.
map_document(MapDocument):
A variable that references a MapDocument object.
out_gif(String):
A string that represents the path and file name for the output export file.
data_frame{Object}:
A variable that references a DataFrame object. Use the string/constant
"PAGE_LAYOUT" to export the map document's page layout instead of an
individual data frame.
df_export_width{Integer}:
A number that defines the width of the export image in pixels for a data
frame export. df_export_width is only used when exporting a data frame.
Exporting a page layout uses the map document page width instead of
df_export_width .
df_export_height{Integer}:
A number that defines the height of the export image in pixels for a data
frame export. df_export_height is only used when exporting a data frame.
Exporting a page layout uses the map document page height instead of
df_export_height .
resolution{Integer}:
A number that defines the resolution of the export file in dots per inch
(DPI).
world_file{Boolean}:
If set to True , a georeferenced world file is created. The file contains
pixel scale information and real-world coordinate information.
color_mode{String}:
This value specifies the number of bits used to describe color.
* 24-BIT_TRUE_COLOR: 24-bit true color.
* 8-BIT_PALETTE: 8-bit palette.
* 8-BIT_GRAYSCALE: 8-bit grayscale.
* 1-BIT_MONOCHROME_MASK: 1-bit monochrome mask.
* 1-BIT_MONOCHROME_THRESHOLD: 1 bit monochrome threshold.
gif_compression{String}:
This value represents a compression scheme.
* LZW: Lempel-Ziv-Welch, a lossless data compression.
* NONE: Compression is not applied.
* RLE: Run-length encoded compression.
background_color{String}:
A defined color is used as a background to the image, or as a mask in the
case of monochrome masked exports.
transparent_color{String}:
A defined color to be displayed as transparent in the image.
interlaced{Boolean}:
If set to True , an interlaced image will be created. An interlaced image
displays as a series of scan lines rather than as a whole image at one
time."""
from .geoprocessing._base import gp_fixargs
from ._mapping import MapDocument, DataFrame
assert isinstance(map_document, MapDocument)
mapdoc = mixins.MapDocumentMixin(map_document)
if data_frame:
assert isinstance(data_frame, DataFrame) or (isinstance(data_frame, basestring) and data_frame.lower() == 'page_layout')
if isinstance(data_frame, basestring):
data_frame = None
layout = data_frame._arc_object if data_frame else mapdoc
args = gp_fixargs((out_gif, df_export_width, df_export_height, resolution, world_file, color_mode, gif_compression, background_color, transparent_color, interlaced))
layout.exportToGIF(*args)
@constants.maskargs
def ExportToJPEG(map_document, out_jpeg, data_frame='PAGE_LAYOUT', df_export_width=640, df_export_height=480, resolution=96, world_file=None, color_mode='24-BIT_TRUE_COLOR', jpeg_quality=100, progressive=False):
"""ExportToJPEG(map_document, out_jpeg, {data_frame}, {df_export_width}, {df_export_height}, {resolution}, {world_file}, {color_mode}, {jpeg_quality}, {progressive})
Exports the page layout or data frame of a map document ( .mxd ) to the
Joint Photographic Experts Group (JPEG) format.
map_document(MapDocument):
A variable that references a MapDocument object.
out_jpeg(String):
A string that represents the path and file name for the output export file.
data_frame{Object}:
A variable that references a DataFrame object. Use the string/constant
"PAGE_LAYOUT" to export the map document's page layout instead of an
individual data frame.
df_export_width{Integer}:
A number that defines the width of the export image in pixels for a data
frame export. df_export_width is only used when exporting a data frame.
Exporting a page layout uses the map document page width instead of
df_export_width .
df_export_height{Integer}:
A number that defines the height of the export image in pixels for a data
frame export. df_export_height is only used when exporting a data frame.
Exporting a page layout uses the map document page height instead of
df_export_height .
resolution{Integer}:
A number that defines the resolution of the export file in dots per inch
(DPI).
world_file{Boolean}:
If set to True , a georeferenced world file is created. The file contains
pixel scale information and real-world coordinate information.
color_mode{String}:
This value specifies the number of bits used to describe color.
* 24-BIT_TRUE_COLOR: 24-bit true color.
* 8-BIT_PALETTE: 8-bit palette.
* 8-BIT_GRAYSCALE: 8-bit grayscale.