1.按照id生成zip压缩包,下载到本地
参考博客
以上博客中提供的arcpy代码文件路径及文件名必须要中文路径,笔者稍作修改,如下:
1)识别中文路径:在inputname后面加上.decode(‘utf-8’).encode(‘gbk’)
inputname.decode('utf-8').encode('gbk')
2)固定名称:不去识别中文路径,而是给压缩包一个固定的名称
outname = ‘result’ + str(cnt)
全部arcpy代码:总体与上述博客相差不多,通过代码生成gp工具后就可以调用,下载zip包到arcgis server的安装路径,通过后台代码从服务器的arcgis server安装路径内下载到本地
# coding:utf8
# Author:PasserQi
# Time:2018/6/15
# Vesrion:0.2.1
# Param:
# - input
# - input_path:the feature class will be selected
# - out_dir:the output dir of the zip file
# - sql:query condition
# - output
# - out_path:the out path of the zip file
# Decs:
# 1. Select elements by attribute
# 2. Generates the SHP file from the selected element in the specified directory
# 3. Package the SHP file to generate the zip file
# 4. Reture the path to the zip file
import arcpy
import os
import sys
import zipfile
# Generate file names without repetition
# Maximum 100 files
def getFileName(inputfilepath,outdir):
ret_filename = None
inputname = os.path.basename(input_path)
if '.'