近期研究了一下GIS开源库shapeLib读写ArcGIS数据的API函数,先整理一下,将各个API的用法介绍一下。
分为两个模块,shape API和DBF API,前者的读取.shp文件的空间几何信息,后者读取.dbf文件的属性信息。
Shape API:
Shape Types (shape类型)
shape文件的类型定义如下:
#define SHPT_NULL 0 2D Shape Types (pre ArcView 3.x): #define SHPT_POINT 1 Points #define SHPT_ARC 3 Arcs (Polylines, possible in parts) #define SHPT_POLYGON 5 Polygons (possible in parts) #define SHPT_MULTIPOINT 8 MultiPoint (related points) 3D Shape Types (may include "measure" values for vertices): #define SHPT_POINTZ 11 #define SHPT_ARCZ 13 #define SHPT_POLYGONZ 15 #define SHPT_MULTIPOINTZ 18 2D + Measure Types: #define SHPT_POINTM 21 #define SHPT_ARCM 23 #define SHPT_POLYGONM 25 #define SHPT_MULTIPOINTM 28 Complex (TIN-like) with Z, and Measure: #define SHPT_MULTIPATCH 31
SHPObject (shape文件中包含的要素对象)
typedef struct { int nSHPType; //Shape Type (SHPT_* - see list above) 要素类型 int nShapeId; //Shape Number (-1 is unknown/unassigned) ID int nParts; //# of Parts (0 implies single part with no info) 要素有几个部分组成 int *panPartStart; //Start Vertex of part 要素部分的起始点 int *panPartType; //Part Type (SHPP_RING if not SHPT_MULTIPATCH) 各个部分的类型 int nVertices; //Vertex list double *padfX; double *padfY; double *padfZ; //(all zero if not