使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务
2015-08-15 17:44
1081 查看
借助ArcGIS桌面发布ArcGIS服务是一个很熟悉的过程了,发布服务的前提是需要拥有一个已连接的ArcGIS Server服务站点,经过对mxd进行制图配置,定义服务参数,才能实现服务的发布,那么这个过程的自动化和一体化又该如何使用python脚本实现呢?直奔主题~~~~
-------------------------欢迎来访,拒绝转载--------------------------
1.创建ArcGIS Server的连接文件:
2. creste service definition draft
3.上传.sddraft的草稿文件(发布服务)
------------------------------欢迎来访,拒绝转载------------------------------
-------------------------欢迎来访,拒绝转载--------------------------
1.创建ArcGIS Server的连接文件:
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # PublishMapService.py # Created on: 2015-08-15 15:49:27.00000 # (generated by HUIHUI) # Usage: # Description: python publish service # --------------------------------------------------------------------------- # Import arcpy module import os as OS import arcpy # createGISServerConnectionFile,define local variable wrkpc = r"\\qnap.geoWindPower.com\WPServices\hh\PublishService\ToolData" //定义一个文件路径 out_folder_path = wrkpc con_Filename = "test.ags" server_url = r"http://gisserver018207.geoWindPower.com/arcgis" //ArcGIS Server站点的URL staging_folder_path = wrkpc username = "admin" //站点用户名 password = "admin" //密码 arcpy.mapping.CreateGISServerConnectionFile("PUBLISH_GIS_SERVICES", out_folder_path, con_Filename, server_url, "ARCGIS_SERVER", False, staging_folder_path, username, password, "S***E_USERNAME")
2. creste service definition draft
# define local variables mxdpath = OS.path.join(wrkpc,"mymxd.mxd") //指定MXD所在的路径 mapDoc = arcpy.mapping.MapDocument(mxdpath) servicename = "GeoTurbine_Test" sddraft = OS.path.join(wrkpc,"GeoTurbine_Test.sddraft") //指定<span style="font-family: Arial, Helvetica, sans-serif;">.sddraft文件所在的路径</span> sd = OS.path.join(wrkpc,"GeoTurbine_Test.sd") connectionfile = <span style="font-family:Arial, Helvetica, sans-serif;font-size:12px;">con_Filename</span> summary = "this is a test" tags = "this is a test" # creste service definition draft analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, servicename, "ARCGIS_SERVER", connectionfile, False, "WP_MapService", summary,tags)
3.上传.sddraft的草稿文件(发布服务)
#stage and upload the service if the sddraft analysis didn't contain errors if analysis['errors'] == {}: # excute StageService arcpy.StageService_server(sddraft,sd) # excute UploadServiceDfinition arcpy.UploadServiceDefinition_server(sd,connectionfile) else: # if the sddraft analysis contained errors,display them print analysis['errors']
------------------------------欢迎来访,拒绝转载------------------------------
相关文章推荐
- 使用Python创建.sd服务定义文件,实现脚本自动发布ArcGIS服务
- 树莓派用Python写几个简单程序3_i2c
- python pandas 如何对一列做四舍五入的操作
- 【Python基础】Python中的协程
- Python 之 glob读取路径下所有文件夹或文件方法
- 树莓派用Python写几个简单程序5:用socket传图像
- python3使用smtplib发电子邮件
- python是一门动态语言
- python 安装scipy
- python2.7学习笔记(5) ——函数
- python Image模块安装
- python第一天学习笔记
- Python的初级语法
- 《机器学习系统设计》之应用scikit-learn做文本分类(下)
- Python初学教程
- python 决策树学习
- python中IndentationError
- Python: 插入数据库报错:Incorrect string value: '\\xE9\\x9C
- 机器学习scikit-learn(一)
- python2.7学习笔记(4) ——条件判断、循环、dict、set