iworkspace
ipws;
iworkspacefactory
ipwsf = new
shapefileworkspacefactoryclass();
ipws = ipwsf.openfromfile(folder, 0);
ifeatureworkspace
ifeatws;
ifeatws = ipws
asifeatureworkspace;
ifields
pfields = new
fieldsclass();
ifield
pfield = new
fieldclass();
ifieldsedit
pfieldsedit = pfields
asifieldsedit;
ifieldedit
pfieldedit = pfield
asifieldedit;
igeometrydef
ipgeodef = new
geometrydefclass();
igeometrydefedit
ipgeodefedit = ipgeodef
asigeometrydefedit;
//igeodataset geodataset = featureclass as igeodataset;
ispatialreference
ipspatialref;
ispatialreferencefactory
spatialreferencefactory = new
spatialreferenceenvironmentclass();
iprojection
projection = spatialreferencefactory.createprojection
((int)esrisrprojectiontype.esrisrprojection_gausskruger);
//土地利用中只採用高斯克呂格
ispheroid
pspheroid = spatialreferencefactory.createspheroid
((int)esrisrspheroidtype.esrisrspheroid_krasovsky1940);
//在土地利用向量資料交換格式中,採用克拉索夫斯基橢球。
ilinearunitedit
lunitedit = new
linearunitclass();
double
unit = 1;
switch (m_headfile.unit_vct.toupper())
ilinearunit
lunit = lunitedit
asilinearunit;
iparameter parameter = new
iparameter[5];
parameter[0] = spatialreferencefactory.createparameter((int)esrisrparametertype.esrisrparameter_falseeasting);//esrisrparametertype.esrisrparameter_falseeasting
parameter[0].value = 500000.000000;
parameter[1] = spatialreferencefactory.createparameter((int)esrisrparametertype.esrisrparameter_falsenorthing);//esrisrparametertype.esrisrparameter_falsenorthing
parameter[1].value = 0;
parameter[2] = spatialreferencefactory.createparameter((int)esrisrparametertype.esrisrparameter_centralmeridian);
parameter[2].value = m_headfile.meridinan;
parameter[3] = spatialreferencefactory.createparameter((int)esrisrparametertype.esrisrparameter_scalefactor);
parameter[3].value = m_headfile.scale;
parameter[4] = spatialreferencefactory.createparameter((int)esrisrparametertype.esrisrparameter_longitudeoforigin);
parameter[4].value = 0;
iprojectedcoordinatesystem
procoord = new
projectedcoordinatesystemclass();
iprojectedcoordinatesystemedit
procoordedit = procoord
asiprojectedcoordinatesystemedit;
igeographiccoordinatesystem
pgcs = creategcs();
pgcs.setdomain(m_headfile.minx, m_headfile.maxx, m_headfile.miny, m_headfile.maxy);
igeographiccoordinatesystem2
pgcs2 = pgcs
asigeographiccoordinatesystem2;
pgcs2.set_leftlongitude(true, 114);
pgcs2.set_rightlongitude(true, 120);
object
name1 = "kass-crug";
object
alias = "utm";
object
abbreviation = "trans_merc";
object
remarks = "transverse mercator is the projection";
object
usage = "";
object
gcs = pgcs;
object
lineunit = lunit;
object
pproject = projection;
object
para = parameter;
procoordedit.define(ref
name1, ref
alias, ref
abbreviation, ref
remarks, ref
usage, ref
gcs, ref
lineunit,
refpproject, ref
para);
/*iunknowncoordinatesystem procoord = new unknowncoordinatesystemclass();*/
//procoord.setdomain(m_headfile.minx, m_headfile.maxx, m_headfile.miny, m_headfile.maxy);
//procoord.set_centralmeridian(true, m_headfile.meridinan);
procoord.scalefactor = m_headfile.scale;
procoord.setdomain(-10000, 10000,-10000, 10000);
/*procoord.set_centralmeridian(true, m_headfile.meridinan);*/
ipspatialref = (ispatialreference)procoord;
ipgeodefedit.geometrytype_2 = shapetype;
宣告結束///
ipgeodefedit.ha**_2 = false;
ipgeodefedit.hasz_2 = false;
ipgeodefedit.spatialreference_2 = ipspatialref;
pfieldedit.name_2 = "shape";
pfieldedit.type_2 = esrifieldtype.esrifieldtypegeometry;
pfieldedit.geometrydef_2 = ipgeodef;
pfieldsedit.addfield(pfield);
///設定shape檔案的基本屬性
featureclass = ifeatws.createfeatureclass(name, pfields, null, null, esrifeaturetype.esrift******, "shape", "");
其中中間一段為設定空間參考,也可以設定為unknown,參考spatialreference.
建立Shapefile檔案並寫入資料的例子
基本思路 使用gdwww.cppcns.comal建立shapefile資料的基本步驟如下 使用osgeo.ogr.driver的createdatasource 方法建立osgeo.ogr.datasource向量資料集 使用osgeo.ogr.datasou的createlayer 方法建立乙個...
scrapy爬蟲建立 開啟
scrapy 是一套基於基於twisted的非同步處理框架,純python實現的爬蟲框架,使用者只需要定製開發幾個模組就可以輕鬆的實現乙個爬蟲,用來抓取網頁內容以及各種,非常之方便 安裝scrapy pip install scrapy 驗證安裝是否成功 import scrapy scrapy.v...
檔案的建立開啟關閉讀寫
檔案輸入輸出函式 creat open close read write lseek等 對於核心而言,所有開啟的檔案都由檔案描述符標識 檔案描述符是乙個非負整數。讀寫檔案時 先呼叫open或creat函式開啟檔案,成功執行時都將返回乙個檔案描述符。在讀寫時將其作為引數傳遞給read或write.檔案...