arcgis pro 如何在应用程序外授权 Python

时间: 2024-05-20 07:14:25 浏览: 10
如果您想在ArcGIS Pro应用程序外授权Python,则需要执行以下步骤: 1. 获得ArcGIS Pro的许可证文件 (.ecp) 2. 从 ArcGIS for Developers 网站下载 ArcGISProSDK.exe。 3. 运行 ArcGISProSDK.exe 安装 ArcGIS Pro SDK。 4. 打开 Visual Studio 并创建一个新的 C# 控制台应用程序。 5. 右键单击项目并选择“管理 NuGet 程序包”。 6. 搜索“Esri.ArcGISRuntime.WPF”并安装该程序包。 7. 将以下代码添加到 Main 方法中: ``` using System; using System.Threading.Tasks; using Esri.ArcGISRuntime; using Esri.ArcGISRuntime.Geometry; using Esri.ArcGISRuntime.Mapping; using Esri.ArcGISRuntime.Security; using Esri.ArcGISRuntime.UI.Controls; namespace ConsoleApp1 { class Program { static void Main(string[] args) { // Set the client ID for authorization. string clientId = "your_client_id_here"; // Call a function to authorize the app with the provided client ID. Task.Run(() => AuthorizeWithPortalAsync(clientId)).Wait(); // Create a map with a basemap. Map myMap = new Map(Basemap.CreateTopographic()); // Create a new map view control. MapView myMapView = new MapView(); // Assign the map to the map view. myMapView.Map = myMap; // Zoom to a specific location. Envelope initialLocation = new Envelope(-118.6919, 34.0205, -118.1909, 34.3114, SpatialReferences.Wgs84); myMapView.SetViewpoint(new Viewpoint(initialLocation)); // Wait for input before exiting. Console.WriteLine("Press ENTER to exit."); Console.ReadLine(); } private static async Task AuthorizeWithPortalAsync(string clientId) { // Register the server information with the AuthenticationManager. ServerInfo serverInfo = new ServerInfo { ServerUri = new Uri("https://www.arcgis.com/sharing/rest"), TokenAuthenticationType = TokenAuthenticationType.OAuthAuthorizationCode, OAuthClientInfo = new OAuthClientInfo { ClientId = clientId, RedirectUri = new Uri("urn:ietf:wg:oauth:2.0:oob") } }; AuthenticationManager.Current.RegisterServer(serverInfo); // Generate a new authorization code. string authorizationCode = await GenerateAuthorizationCodeAsync(); // Get a token using the authorization code. await AuthenticationManager.Current.GenerateTokenAsync(serverInfo, authorizationCode); } private static async Task<string> GenerateAuthorizationCodeAsync() { // Create a new instance of the authentication view model. AuthenticationViewModel authViewModel = new AuthenticationViewModel(); // Show the authentication view. bool success = await AuthenticationManager.Current.ShowOAuthAuthorizeDialogAsync(authViewModel); // If the user authorized the app, return the authorization code. if (success) { return authViewModel.AuthorizationCode; } // If the user didn't authorize the app, throw an exception. throw new Exception("Authorization failed."); } } } ``` 8. 替换代码中的“your_client_id_here”为您的 ArcGIS 开发者帐户的客户端 ID。 9. 运行应用程序并按照屏幕上的提示进行操作以完成授权。 完成以上步骤后,您的应用程序就可以在授权之后使用 ArcGIS Pro 的 Python 功能了。

相关推荐

最新推荐

recommend-type

arcgis pro 2.2安装

掌握ArcGIS Pro入门知识的第一步是下载和安装此应用程序。还可以使用一些提供离线帮助的可选安装程序,并可以使用允许您以首选语言运行ArcGIS Pro的语言包。您可以获取ArcGIS Pro(如果您当前处于ArcGIS Desktop维护...
recommend-type

ArcGIS Python常用脚本.docx

ArcGIS Python常用脚本 日常经常用到的arcpy源码 来源网络 仅整理
recommend-type

arcgis pro生成矢量切片详细步骤

使用arcgis Pro导出矢量瓦片包(vtpk)详细步骤说明 使用arcgis Pro导出矢量瓦片包(vtpk)详细步骤说明
recommend-type

arcgis_pro导入3d模型并发布三维场景

请勿在未经授权的情况下上传任何涉及著作权侵权的资源,除非该资源完全由您个人创作
recommend-type

ArcGIS API for Python学习笔记(一)环境配置

ArcGIS API for Python开发环境配置 因为学习需要,尝试使用Pyhton API,但在使用过程中踩雷不少,特立贴记录。 主要参考教程: ESRI官网环境配置教程 1. 前言 2. Python安装 3. Anaconda安装 4. ArcGIS API开发...
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

MATLAB柱状图在信号处理中的应用:可视化信号特征和频谱分析

![matlab画柱状图](https://img-blog.csdnimg.cn/3f32348f1c9c4481a6f5931993732f97.png) # 1. MATLAB柱状图概述** MATLAB柱状图是一种图形化工具,用于可视化数据中不同类别或组的分布情况。它通过绘制垂直条形来表示每个类别或组中的数据值。柱状图在信号处理中广泛用于可视化信号特征和进行频谱分析。 柱状图的优点在于其简单易懂,能够直观地展示数据分布。在信号处理中,柱状图可以帮助工程师识别信号中的模式、趋势和异常情况,从而为信号分析和处理提供有价值的见解。 # 2. 柱状图在信号处理中的应用 柱状图在信号处理
recommend-type

hive中 的Metastore

Hive中的Metastore是一个关键的组件,它用于存储和管理Hive中的元数据。这些元数据包括表名、列名、表的数据类型、分区信息、表的存储位置等信息。Hive的查询和分析都需要Metastore来管理和访问这些元数据。 Metastore可以使用不同的后端存储来存储元数据,例如MySQL、PostgreSQL、Oracle等关系型数据库,或者Hadoop分布式文件系统中的HDFS。Metastore还提供了API,使得开发人员可以通过编程方式访问元数据。 Metastore的另一个重要功能是跟踪表的版本和历史。当用户对表进行更改时,Metastore会记录这些更改,并且可以让用户回滚到
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。