-
整理
Python 3.x
中的各种与地信, 遥感有关的常用库的使用方法和应用案例.
To summerize usages and appliances of common libraries inPython 3.x
related to GIS/RS. -
整理
arcpy
模块(基于ArcGIS Desktop
和Python 2.x
32位)在空间数据自动处理中的使用方法和应用案例.
To summerize usages and appliances of modulearcpy
(based onArcGIS Desktop
andPython 2.x
32-bit) in automation of spatial data processing. -
整理
idlpy
模块(基于ENVI 5.x
/IDL 8.x
和 "Python to IDL Bridge")在IDl
与Python
对接,ENVI
遥感数据处理与交互中的使用方法和应用案例.
To summarize usages and appliances of moduleidlpy
(based onENVI 5.x
/IDL 8.x
and "Python to IDL Bridge") in dockingIDL
withPython
, and RS data processing and interaction inENVI
. -
将
arcpy
和idlpy
嵌入至现有的Python
交互式编辑器中, 以供集成使用, 并使用"笔记本式"文档管理代码块.
To embedarcpy
andidlpy
into existent interactive editor for Python for intergrated usage. Meanwhile, use notebook-style document for codeblock management.
- 基本数学运算库.
Libraries for fundermental mathematical operation.math
,cmath
decimal
,fractions
statistics
,random
- 字符串和文本文件处理相关库.
Libraries for processing of character strings and text files.string
,re
sys
,os
,io
- 与GIS/RS有关的可交换文本文件导入导出, 如
JSON
/GeoJSON
,XML
/KML
.
Libraries for import and export of GIS/RS-related exchangable textual files, e.g.JSON
/GeoJSON
,XML
/KML
json
,xml
- 数学建模, 数据挖掘, 通用科学数据计算相关库.
Libraries for mathematical modeling, data mining and general scientific data computation.numpy
scipy
pandas
ArcGIS Desktop
的Python 2.x
接口.
Python 2.x
interface ofArcGIS Desktop
.arcpy
IDL
/ENVI
的Python 2.x
接口 (Python to IDL Bridge).
Python 2.x
interface ofIDL
/ENVI
(Python to IDL Bridge).idlpy
项目 Item |
值 Value |
---|---|
处理器架构 Architecture of processor |
Intel x86-64 |
操作系统内核 OS kernel version |
Windows NT 6.1.7601 |
Conda 管理器版本Conda package manager version |
conda 4.7.12 (python 3.7.4 , requests 2.22.0 ) |
Anaconda 发行版Anaconda system release version |
anaconda 2019.10 |
ArcGIS 发行版ArcGIS release version |
ArcGIS Desktop 10.5 |
ENVI 发行版ENVI release version |
ENVI 5.3 |
本项目通过anaconda
环境管理器, 创建一个名为arcpy_idlpy_x32
的子环境, 集成arcpy
和idlpy
以供二次开发使用. 上述二次开发接口对接的软件具有以下特征:
This repository creates an environment named arcpy_idlpy_x32
via anaconda
environment manager, which intergrates arcpy
and idlpy
for secondary development. Softwares docked by interfaces above contains features as follow:
-
ArcGIS Desktop 10.x
主软件可在32位或64位系统下运行, 但附带的python
解释器为python 2.x
版本, 仅包含32位版本.
The master product ofArcGIS Desktop 10.x
can run on 32-bit or 64-bit systems, while itspython
interpreter ispython 2.x
, containing 32-bit release only. -
ENVI 5.3
/IDL 8.5
的python
接口 (Python to IDL Bridge) 支持python 2.x
/3.x
, 同时提供32位和64位版本.
Thepython
interface ofENVI 5.3
/IDL 8.5
(Python to IDL Bridge) supportspython 2.x
/3.x
, providing both 32-bit and 64-bit releases.
因此, 需要创建一个相对独立的, 32位的python 2.x
环境, 用于运行解释器并调用相关程序包.
Therefore, creation of a standlone 32-bit python 2.x
environment to run interpreter and invoke relative packages is required.
Important
在执行后续操作前, 可能需要关闭反病毒软件和第三方防火墙软件, 因为上述软件可能会阻止anaconda
从镜像源下载程序包.
Before execution of following operations, developers are supposed to disable anti-virus softwares and third-party firewalls, which may block anaconda
from downloading packages from mirror websites.
ArcGIS Desktop 10.x
在Windows系统中安装时, 安装向导会在准备阶段分两步指定ArcGIS
主软件, 及其python
解释器的安装目录, 这两个目录可能不同. 因此, 需要将二者区分开来. 需要确定 ArcGIS
的python
解释器所在目录以完成后续操作.
During installation of ArcGIS Desktop 10.x
on Windows, installation wizard will assign directories of ArcGIS
master product, and its python
interpreter, in two steps separately. Directories above may be different and need to be distinguished. To archive further operations, developers are supposed to verify directory in which the python
interpreter of ArcGIS
locates.
在Anaconda prompt
命令行中, 将 ArcGIS
的python
解释器所在目录设置为临时变量.
In Anaconda prompt
, set a temporary variable to store the path of the python
interpreter of ArcGIS
.
Note
本文档中以绝对路径(以盘符开头)表示的安装路径仅供参考. 请以开发用机上python
解释器的实际安装路径为准.
In current document, installation paths represented as ABSOLUTE paths (beginning with drive letter) are FOR REFERENCE ONLY. Please consult installation path of python
interpreter de facto.
set pyarcgis=D:\python27\ArcGIS10.5
Important
临时变量的值仅在当前命令行会话中有效, 命令行关闭后将被清理或者复原.
执行上述命令后, 请勿关闭命令行界面, 以便在后续命令中继续使用临时变量. 后续操作均在同一控制台中执行.
Values of temporary variables are valid in CURRENT CLI SESSION ONLY and will be cleared or restored after closing the console.
After excuting command above, do NOT close CLI, so that variables can be reused in following commands. Further operations will be executed in THE SAME CONSOLE.
在Anaconda prompt
命令行中, 将IDL
安装目录设置为临时变量.
In Anaconda prompt
, set a temporary variable to store the installation path of IDL
interpreter.
set idl=D:\Exelis\IDL85
Note
上述路径不是IDL的解释器(idl.exe
或者idlrt.exe
)所在的路径.
路径下包含bin
, examples
, external
, help
, lib
, resource
等子目录.
Path above is NOT the path where the interpreters of IDL (idl.exe
or idlrt.exe
) locate.
This path contains subdirectories including bin
, examples
, external
, help
, lib
, resource
.
在Anaconda prompt
命令行中, 将anaconda
安装目录设置为临时变量.
In Anaconda prompt
, set a temporary variable to store the installation path of anaconda
.
set anacon=D:\Anaconda3
- 为建立新环境初始化
anaconda
系统参数.
Initialize parameters ofanaconda
for creation of new environment.
set CONDA_FORCE_32BIT=1
conda clean -i
- 建立并进入新环境
arcpy_idlpy_x32
.
Create and enter new environmentarcpy_idlpy_x32
.
conda create -n arcpy_idlpy_x32 python==2.7.12 pip==8.1.1 wheel==0.29.0 -y
conda activate arcpy_idlpy_x32
- 在新环境中配置与
ipython
有关的包.
Configure packages related toipython
in new environment.
conda install notebook ipykernel numpy==1.9.3 six==1.10.0 tornado==4.5.3 -y
- 将
ArcGIS
的python
解释器使用的部分包链接到新环境下. Link several packages used bypython
interpreter ofArcGIS
to new environment.
chdir /D %anacon%\envs\arcpy_idlpy_x32\Lib\site-packages
mklink /D scipy %pyarcgis%\Lib\site-packages\scipy
mklink /D pandas %pyarcgis%\Lib\site-packages\pandas
mklink /D matplotlib %pyarcgis%\Lib\site-packages\matplotlib
mklink /D pytz %pyarcgis%\Lib\site-packages\pytz
mklink pyparsing.py %pyarcgis%\Lib\site-packages\pyparsing.py
mklink pyparsing.pyc %pyarcgis%\Lib\site-packages\pyparsing.pycpytz
mklink cycler.py %pyarcgis%\Lib\site-packages\cycler.py
mklink cycler.pyc %pyarcgis%\Lib\site-packages\cycler.pyc
- 将
arcpy
的路径配置文件链接到新环境下.
Link path configuration file ofarcpy
to new environment.
mklink Desktop10.5.pth %pyarcgis%\Lib\site-packages\Desktop10.5.pth
- 在新环境下建立
idlpy
的路径配置文件.
Create path configuration file ofidlpy
in new environment.
echo %idl%\bin\bin.x86 >IDL8.5.pth
echo %idl%\lib\bridges >>IDL8.5.pth
- 将新环境注册为
ipython
内核, 以便与base
环境下的Jupyter notebook
一同使用.
Register new environment as anipython
kernel for use withJupyter notebook
inbase
environment.
pip install backports.functools_lru_cache
ipython kernelspec install-self
Note
如果内核注册不成功(发生报错), 一般是因为pip
未能向环境内成功安装上述库, 如遇上述现象, 需要再通过conda
安装该库.
The faliure of kernel registration is generally caused by faliure of installation of library above via pip
, In case of phenomenon above, it is required to install this library via conda
again.
conda install backports.functools_lru_cache
- 完成新环境配置.
Finish configuration of new environment.
conda deactivate
set CONDA_FORCE_32BIT=.
使用集成环境中的部分数据分析和科学计算相关库 / Use Libraries for Data Analysis and Scientific Computation in Integrated Environment
对应的import
语句需要重复调用多次, 才可正常导入模块. 需要在代码开头声明以下语句:
Only by invoking corresponding import
statements repeatedly can modules be imported properly. It is required to declare following statements at the beginning of your code:
module_imported = False;
while not(module_imported):
try:
import numpy, scipy, pandas;
except SyntaxError:
continue;
else:
break;
直接使用一次import
语句即可.
Directly use import
statements once.
import arcpy, idlpy;