HowTo:  Insert images into a BLOB field

相关信息
Article ID: 41179
Software:
ArcSDE 10.1
ArcGIS for Desktop Advanced 10.1
ArcGIS for Desktop Standard 10.1
Platforms:
Windows Server 2003, Vista, Server 2008, Windows 7

问题描述
GIS programmers and managers sometimes find it necessary to insert images into a BLOB (binary large object) field for third-party applications. The below script demonstrates how to do this as well as inserting XY coordinates for the SHAPE column of a feature class.
已邀请:

易智瑞技术支持

赞同来自:

解决方案
Modify the below parameters for the particular environment:


#python list containing list of images and XY coordinates to be inserted
row_vals = [(('C:/Data/test.jpg'),(50,70)),(('C:/Data/test.jpg'),(50,90)) ]

#name of blob field
blob_field = 'pic'

#feature class containing blob field
input_table = "C:\Data\sde_to_sde.sde\sde.SDE.blobtest"

#path to raster or image to be inserted
raster = r"C:\Data\test.jpg"




import arcpy
from arcpy import da
import sys, string, os

def InsertBlob(row_vals, blob_field, input_table, raster):

cursor = arcpy.da.InsertCursor(input_table, (blob_field,"SHAPE@XY"))

for row in row_vals:
cursor.insertRow(row)
print "Inserting unique values {0}".format(row[0])

if __name__ == "__main__":

row_vals = [(('C:/Data/test.jpg'),(50,70)),(('C:/Data/test.jpg'),(50,90)) ]
blob_field = 'pic'
input_table = r"C:\Data\sde_to_sde.sde\sde.SDE.blobtest"
raster = r"C:\Data\test.jpg"
InsertBlob(row_vals, blob_field, input_table, raster)





创建及修改时间
Created: 5/16/2013

Last Modified: 8/6/2013
原文链接
http://support.esri.com/en/kno ... 41179

要回复问题请先登录注册