gis服务器上怎么新建文件夹,上传服务定义 (服务器)

代码示例UploadServiceDefinition 示例 1(独立脚本)

以下脚本将地图中的图层列表作为 web 切片图层发布至 ArcGIS Enterprise 或 ArcGIS Online。门户信息可从 ArcGIS Pro 的门户页面中获得。

import arcpy

import os

# Set output file names

outdir = r"C:\Project\Output"

service = "TileSharingDraftExample"

sddraft_filename = service + ".sddraft"

sddraft_output_filename = os.path.join(outdir, sddraft_filename)

# Reference map to publish

aprx = arcpy.mp.ArcGISProject(r"C:\Project\World.aprx")

m = aprx.listMaps("World")[0]

lyrs = []

lyrs.append(m.listLayers('cities')[0])

lyrs.append(m.listLayers('counties')[0])

# Create TileSharingDraft and set service properties

sharing_draft = m.getWebLayerSharingDraft("HOSTING_SERVER", "TILE", service, lyrs)

sharing_draft.summary = "My Summary"

sharing_draft.tags = "My Tags"

sharing_draft.description = "My Description"

sharing_draft.credits = "My Credits"

sharing_draft.useLimitations = "My Use Limitations"

# Create Service Definition Draft file

sharing_draft.exportToSDDraft(sddraft_output_filename)

# Stage Service

sd_filename = service + ".sd"

sd_output_filename = os.path.join(outdir, sd_filename)

arcpy.StageService_server(sddraft_output_filename, sd_output_filename)

# Share to portal

print("Uploading Service Definition...")

arcpy.UploadServiceDefinition_server(sd_output_filename, "My Hosted Services")

print("Successfully Uploaded service.")UploadServiceDefinition 示例 2(独立脚本)

以下脚本可上传现有的服务定义并可使用可选参数对该服务的属性进行修改。

import arcpy

# Set environment settings

arcpy.env.workspace = "C:/data"

# Set local variables

inSdFile = "myMapService.sd"

inServer = "myServerConnection.ags"

inServiceName = "newServiceName"

inCluster = "myCluster"

inFolderType = "NEW"

inFolder = "newFolder"

inStartup = "STOPPED"

# Execute UploadServiceDefinition

arcpy.UploadServiceDefinition_server(inSdFile, inServer, inServiceName,

inCluster, inFolderType, inFolder,

inStartup)UploadServiceDefinition 示例 3(独立脚本)

以下脚本可将现有的服务定义上传到 ArcGIS Online 或 ArcGIS Enterprise 并可使用可选参数对该服务的属性进行修改。

import arcpy

# Set environment settings arcpy.env.workspace = "C:/data"

# Set local variables inSdFile = "myMapService.sd"

inServer = "HOSTING_SERVER"

inServiceName = "newServiceName"

inCluster = "myCluster"

inFolderType = "EXISTING"

inFolder = "existingFolder"

inStartup = "STOPPED"

inOverride = "OVERRIDE_DEFINITION"

inMyContents = "SHARE_ONLINE"

inPublic = "PRIVATE"

inOrganization = "NO_SHARE_ORGANIZATION"

inGroups = ["My Group", "MyGroup 2"]

# Execute UploadServiceDefinition arcpy.UploadServiceDefinition_server(inSdFile, inServer, inServiceName, inCluster, inFolderType, inFolder,

inStartup, inOverride, inMyContents, inPublic, inOrganization, inGroups)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值