本文整理汇总了C#中ITable.FindField方法的典型用法代码示例。如果您正苦于以下问题:C# ITable.FindField方法的具体用法?C# ITable.FindField怎么用?C# ITable.FindField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITable
的用法示例。
在下文中一共展示了ITable.FindField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: dataPrepTTest
public dataPrepTTest(ITable table, string[] variables, string strataField)
{
InTable = table;
VariableFieldNames = variables;
if (strataField == "" || strataField == null)
{
if (InTable.FindField("gr") > -1) StrataField = "gr";
else StrataField = addConstantGroupField();
}
else
{
StrataField = strataField;
}
buildModel();
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:15,代码来源:dataPrepTTest.cs
示例2: dataPrepPairedTTest
public dataPrepPairedTTest(ITable table, string[] variables, string strataField)
{
InTable = table;
VariableFieldNames = variables;
if (strataField == "" || strataField == null)
{
if (InTable.FindField("gr") > -1) StrataField = "gr";
else StrataField = addConstantGroupField();
}
else
{
StrataField = strataField;
}
IDataset dSet = (IDataset)table;
inpath = dSet.Workspace.PathName + "\\" + dSet.BrowseName;
buildModel();
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:17,代码来源:dataPrepPairedTTest.cs
示例3: addField
public static void addField(ITable pTable, string FieldName, ESRI.ArcGIS.Geodatabase.esriFieldType FieldType, int FieldLength, int FieldPrecision, int FieldScale = 0)
{
// Error Handling
const string functionName = "addField";
IField pField = new Field();
IFieldEdit pFieldEdit = pField as IFieldEdit;
try
{
if (pTable.FindField(FieldName) < 0)
{
pFieldEdit.Name_2 = FieldName;
pFieldEdit.Type_2 = FieldType;
pFieldEdit.Length_2 = FieldLength;
if (FieldType != ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeString)
{
pFieldEdit.Precision_2 = FieldPrecision;
pFieldEdit.Scale_2 = FieldScale;
}
pField = pFieldEdit as IField;
pTable.AddField(pField);
}
}
catch (Exception e)
{
MessageBox.Show(functionName + " :: " + e.Message, "SF10", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
pField = null;
pFieldEdit = null;
}
}
示例4: FixBug
public bool FixBug(ITable pTable, string pFromField, object pValue)
{
int pIndex = pTable.FindField(pFromField);
try
{
if (pIndex != -1)
{
ICursor pCursor = pTable.Update(null, false);
IRow pRow = pCursor.NextRow();
while (pRow != null)
{
//string pData = pFileName.Substring(0, 4) + "-" + pFileName.Substring(4, 2) + "-" + pDay.ToString("00") + " " + pHour.ToString() + ":" + pFileName.Substring(10, 2) + ":00";
pRow.set_Value(pIndex, pValue);
pCursor.UpdateRow(pRow);
pRow = pCursor.NextRow();
}
}
}
catch (System.Exception ex)
{
return false;
}
return true;
}
示例5: SearchForFields
public override void SearchForFields(ITable tab)
{
//TIER 1: File/SDE Geodatabase
length_field_index = tab.FindField("Shape_Length");
fieldTier = 1;
//TIER 2: Shapefile with LENGTH fields already present
if (length_field_index == -1)
{
length_field_index = tab.FindField("LENG");
length_field_unit_index = tab.FindField("L_UNIT");
fieldTier = 2;
}
//TIER 3: Neither present. Need to add field and calculate
if (length_field_index == -1)
{
length_field_index = AddNewField((IClass)tab, "LENG");
length_field_unit_index = AddNewField((IClass)tab, "L_UNIT");
fieldTier = 3;
doReCalcValues = true;
}
}
示例6: calcBinValues
private Dictionary<string, object[]> calcBinValues(Statistics.dataPrepCompareSamples dpComp, ITable inTable)
{
Statistics.dataPrepClusterKmean clus = dpComp.Cluster;
int nBins = clus.Classes ;
Dictionary<string, object[]> outDic = new Dictionary<string, object[]>();//{double[10],int[10],double} ratios, counts, weight
//Dictionary<string, double> minDic = new Dictionary<string, double>();//the min value of each bin
//Dictionary<string, double> spanDic = new Dictionary<string, double>();//the span of each bin
Dictionary<string, int> cntDic = new Dictionary<string,int>();//counts by class
//Statistics.dataPrepPrincipleComponents pca = dpComp.PCA;
string[] labels = dpComp.Labels;
for (int i = 0; i < labels.Length; i++)
{
string lbl = labels[i];
//double[][] minmax1 = dpComp.minMaxDic1[lbl];
//double[][] minmax2 = dpComp.minMaxDic2[lbl];
//nBins = dpComp.binPropDic1[lbl][0].Length;
//double min = minmax1[0][0];
//if (minmax2[0][0] < min) min = minmax2[0][0];
//double max = minmax1[1][0];
//if (minmax2[1][0] > max) max = minmax2[1][0];
//double span = (max - min) / nBins;
//minDic.Add(lbl, min);
//spanDic.Add(lbl, span);
cntDic.Add(lbl,0);
double[] ratios = new double[nBins];
int[] cnts = new int[nBins];
object[] outObjectValues = new object[3];
outObjectValues[0] = ratios;
outObjectValues[1] = cnts;
outObjectValues[2] = 1;
outDic.Add(lbl, outObjectValues);
}
int[] vArrIndex = new int[dpComp.Variables.Length];
for (int i = 0; i < vArrIndex.Length; i++)
{
vArrIndex[i]=inTable.FindField(dpComp.Variables[i]);
}
string binFldName = geoUtil.createField(inTable, "BIN", esriFieldType.esriFieldTypeInteger, false);
string strataFldName = dpComp.StrataField;
string weightFldName = "Weight";
int binFldNameIndex = inTable.FindField(binFldName);
int strataFldNameIndex = inTable.FindField(strataFldName);
int weightFldNameINdex = inTable.FindField(weightFldName);
ICursor cur = inTable.Update(null, false);
IRow rw = cur.NextRow();
double[] varr = new double[vArrIndex.Length];
int totalCnt = 0;
while (rw != null)
{
bool check = true;
for (int i = 0; i < varr.Length; i++)
{
object vlObj = rw.get_Value(vArrIndex[i]);
if(vlObj==null)
{
check = false;
break;
}
varr[i]=System.Convert.ToDouble(vlObj);
}
if(check)
{
int vl = clus.computNew(varr);
//double min;
//double span;
string g = labels[0];
object w = 1;
if(strataFldNameIndex>-1)
{
g = rw.get_Value(strataFldNameIndex).ToString();
}
if (weightFldNameINdex > -1)
{
w = rw.get_Value(weightFldNameINdex);
}
object[] oOut = outDic[g];
int[] cntArr = (int[])oOut[1];
oOut[2] = w;
//min = minDic[g];
//span = spanDic[g];
//weightDic[g] = w;
cntDic[g] += 1;
//int b = (int)((vl-min)/span);
//if (b >= cntArr.Length) b = cntArr.Length - 1;
//if (b < 0) b = 0;
//Console.WriteLine("\nValue = " + vl.ToString() + "\nmin = " + min.ToString() + "\nSpan = " + span.ToString() + "\nbin = " + b.ToString());
cntArr[vl] = cntArr[vl]+1;
rw.set_Value(binFldNameIndex,vl);
cur.UpdateRow(rw);
totalCnt+=1;
}
rw = cur.NextRow();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
Dictionary<string, double[]> clusterProp = dpComp.ClusterProportions;
foreach(KeyValuePair<string,object[]> kvp in outDic)
{
string ky = kvp.Key;
int gCnt = cntDic[ky];
//.........这里部分代码省略.........
示例7: buildZoneClassCount
private void buildZoneClassCount()
{
string cTblName = geoUtil.getSafeOutputNameNonRaster(wks,tblName.Replace("_VAT","_CLASS"));
if (rd != null) rd.addMessage("Output table name = " + wks.PathName + "\\" + cTblName);
IFields nflds = new FieldsClass();
IFieldsEdit nfldsE = (IFieldsEdit)nflds;
IField nfld = new FieldClass();
IFieldEdit nfldE = (IFieldEdit)nfld;
nfldE.Name_2 = "Band";
nfldE.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfldE);
IField nfld2 = new FieldClass();
IFieldEdit nfld2E = (IFieldEdit)nfld2;
nfld2E.Name_2 = "Zone";
nfld2E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld2E);
IField nfld4 = new FieldClass();
IFieldEdit nfld4E = (IFieldEdit)nfld4;
nfld4E.Name_2 = "Class";
nfld4E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld4E);
IField nfld3 = new FieldClass();
IFieldEdit nfld3E = (IFieldEdit)nfld3;
nfld3E.Name_2 = "Count";
nfld3E.Type_2 = esriFieldType.esriFieldTypeDouble;
nfldsE.AddField(nfld3E);
oTbl2 = geoUtil.createTable(wks,cTblName,nflds);
IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
if (wksE.IsBeingEdited())
{
wksE.StopEditing(true);
}
//ITransactions trs = (ITransactions)wks;
//trs.StartTransaction();
try
{
int bdIndex = oTbl2.FindField("Band");
int vlIndex = oTbl2.FindField("Zone");
int cntIndex = oTbl2.FindField("Count");
int clsIndex = oTbl2.FindField("Class");
int bndCnt = 1;
ICursor cur = oTbl2.Insert(true);
IRowBuffer rw = oTbl2.CreateRowBuffer();
foreach (Dictionary<double, object[]> zoneValueDicOut in zoneValueDicArr)
{
foreach (KeyValuePair<double, object[]> kVp in zoneValueDicOut)
{
double key = kVp.Key;
object[] vl = kVp.Value;
Dictionary<double, int> uDic = (Dictionary<double, int>)vl[5];
foreach(KeyValuePair<double,int> uKvp in uDic)
{
double uDicKey = uKvp.Key;
int uDicVl = uKvp.Value;
rw.set_Value(bdIndex, bndCnt);
rw.set_Value(vlIndex, key);
rw.set_Value(cntIndex, uDicVl);
rw.set_Value(clsIndex, uDicKey);
cur.InsertRow(rw);
}
}
bndCnt += 1;
}
cur.Flush();
System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
System.Runtime.InteropServices.Marshal.ReleaseComObject(rw);
//trs.CommitTransaction();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
//trs.AbortTransaction();
}
finally
{
}
}
示例8: writeDataInExcle
private void writeDataInExcle(HSSFSheet hssfSheet, ITable table)
{
int rownum = table.RowCount(null);
int colnum = table.Fields.FieldCount;
//int myindex1 = table.FindField("FID");
int myindex2 = table.FindField("FinalScore");
//IField field1 = null;
IField field2 = null;
//field1 = table.Fields.get_Field(myindex1);
field2 = table.Fields.get_Field(myindex2);
// write header
NPOI.SS.UserModel.IRow row = hssfSheet.CreateRow(0);
//row.CreateCell(0).SetCellValue(field1.Name.ToString());
row.CreateCell(0).SetCellValue(field2.Name.ToString());
// write data
ICursor cursor = table.Search(null, true);
IRow trow = cursor.NextRow();
int i = 1;
while (trow != null)
{
row = hssfSheet.CreateRow(i);
//row.CreateCell(0).SetCellValue(Convert.ToDouble(trow.get_Value(myindex1)));
row.CreateCell(0).SetCellValue(Convert.ToDouble(trow.get_Value(myindex2)));
trow = cursor.NextRow();
i++;
}
}
示例9: selectStrataFeaturesToSample
public void selectStrataFeaturesToSample(ITable inputTable, string strataModelPath, string strataFieldName = "Cluster", double proportionOfMean = 0.1, double alpha = 0.05, bool weightsEqual = false)
{
IObjectClassInfo2 objInfo2 = (IObjectClassInfo2)inputTable;
if (!objInfo2.CanBypassEditSession())
{
System.Windows.Forms.MessageBox.Show("Input Table participates in a composite relationship. Please export this table as a new table and try again!");
return;
}
esriUtil.Statistics.dataPrepStrata dpC = new Statistics.dataPrepStrata();
dpC.buildModel(strataModelPath);
List<string> labels = dpC.Labels;
HashSet<string> unqVls = geoUtil.getUniqueValues(inputTable, strataFieldName);
System.Random rd = new Random();
int[] samplesPerCluster = esriUtil.Statistics.dataPrepSampleSize.sampleSizeMaxCluster(strataModelPath, proportionOfMean, alpha);
double[] propPerCluster = esriUtil.Statistics.dataPrepSampleSize.clusterProportions(strataModelPath);
double[] weightsPerCluster = new double[propPerCluster.Length];
double sSamp = System.Convert.ToDouble(samplesPerCluster.Sum());
for (int i = 0; i < weightsPerCluster.Length; i++)
{
weightsPerCluster[i] = propPerCluster[i] / (samplesPerCluster[i] / sSamp);
}
if (weightsEqual)
{
double minProp = weightsPerCluster.Min();
for (int i = 0; i < samplesPerCluster.Length; i++)
{
samplesPerCluster[i] = System.Convert.ToInt32(samplesPerCluster[i] * (weightsPerCluster[i] / minProp));
weightsPerCluster[i] = 1;
}
}
int[] tsPerCluster = new int[propPerCluster.Length];
double[] randomRatioPerClust = new double[propPerCluster.Length];
if (samplesPerCluster.Length != unqVls.Count)
{
System.Windows.Forms.MessageBox.Show("Unique Values in cluster field do not match the number of cluster models!");
return;
}
string sampleFldName = geoUtil.createField(inputTable, "sample", esriFieldType.esriFieldTypeSmallInteger, false);
string weightFldName = geoUtil.createField(inputTable, "weight", esriFieldType.esriFieldTypeDouble, false);
IQueryFilter qf0 = new QueryFilterClass();
qf0.SubFields = strataFieldName;
string h = "";
IField fld = inputTable.Fields.get_Field(inputTable.FindField(strataFieldName));
if (fld.Type == esriFieldType.esriFieldTypeString) h = "'";
for (int i = 0; i < samplesPerCluster.Length; i++)
{
qf0.WhereClause = strataFieldName + " = " + h + labels[i] + h;
int tCnt = inputTable.RowCount(qf0);
tsPerCluster[i] = tCnt;
randomRatioPerClust[i] = System.Convert.ToDouble(samplesPerCluster[i]) / tCnt;
}
IQueryFilter qf = new QueryFilterClass();
qf.SubFields = strataFieldName + "," + sampleFldName + "," + weightFldName;
IWorkspace wks = ((IDataset)inputTable).Workspace;
IWorkspaceEdit wksE = (IWorkspaceEdit)wks;
if (wksE.IsBeingEdited())
{
wksE.StopEditing(true);
}
try
{
ICursor cur = inputTable.Update(qf, false);
int sIndex = cur.FindField(sampleFldName);
int cIndex = cur.FindField(strataFieldName);
int wIndex = cur.FindField(weightFldName);
IRow rw = cur.NextRow();
while (rw != null)
{
string clustStr = rw.get_Value(cIndex).ToString();
int clust = labels.IndexOf(clustStr);
double w = weightsPerCluster[clust];
double rNum = rd.NextDouble();
int ss = 0;
double r = randomRatioPerClust[clust];
if (rNum < r)
{
ss = 1;
}
rw.set_Value(sIndex, ss);
rw.set_Value(wIndex, w);
cur.UpdateRow(rw);
rw = cur.NextRow();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
}
}
示例10: UpdateHistoryOnLines
public bool UpdateHistoryOnLines(ITable pLinesTable, ITable pPointsTable,
int iParcelCount, ICadastralFabric pCadFabric, List<string> sOIDList,
Dictionary<int, string> ParcelToHistory_DICT, IStepProgressor m_pStepProgressor, ITrackCancel m_pTrackCancel)
{
bool m_bShowProgressor = (iParcelCount > 10);
sOIDList.Add("");
int tokenLimit = 995;
bool bCont = true;
int j = 0;
int iCounter = 0;
ICadastralFabricSchemaEdit2 pSchemaEd = null;
try
{
#region update line table history
//Get the line table history fields
//SystemStart, SystemEnd, LegalStart, LegalEnd, Historic
int iParcelID = pLinesTable.FindField("parcelid");
string sParcelID = pLinesTable.Fields.get_Field(iParcelID).Name;
int iLineSysStartDate = pLinesTable.FindField("systemstartdate");
string sLineSysStartDate = pLinesTable.Fields.get_Field(iLineSysStartDate).Name;
int iLineSysEndDate = pLinesTable.FindField("systemenddate");
string sLineSysEndDate = pLinesTable.Fields.get_Field(iLineSysEndDate).Name;
int iLineLegalStartDate = pLinesTable.FindField("legalstartdate");
string sLineLegalStartDate = pLinesTable.Fields.get_Field(iLineLegalStartDate).Name;
int iLineLegalEndDate = pLinesTable.FindField("legalenddate");
string sLineLegalEndDate = pLinesTable.Fields.get_Field(iLineLegalEndDate).Name;
int iLineHistorical = pLinesTable.FindField("historical");
string sLineHistorical = pLinesTable.Fields.get_Field(iLineHistorical).Name;
int iFromPoint = pLinesTable.FindField("frompointid");
string sFromPoint = pLinesTable.Fields.get_Field(iFromPoint).Name;
int iToPoint = pLinesTable.FindField("topointid");
string sToPoint = pLinesTable.Fields.get_Field(iToPoint).Name;
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.SubFields = pLinesTable.OIDFieldName + ", parcelid," + sLineSysStartDate +
"," + sLineSysEndDate + "," + sLineLegalStartDate + "," + sLineLegalEndDate +
"," + sLineHistorical + "," + sFromPoint + "," + sToPoint;
pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
pSchemaEd.ReleaseReadOnlyFields(pLinesTable, esriCadastralFabricTable.esriCFTLines); //release safety-catch
Dictionary<int, string> PointToHistory_DICT = new Dictionary<int, string>(iParcelCount);
List<string> sPointOIDList = new List<string>();
List<int> iLinesOIDList = new List<int>();
sPointOIDList.Add("");
j = iCounter = 0;
ICursor pCur = null;
object obj = null;
foreach (string sHistory in sOIDList)
{
if (sHistory.Trim() == "")
continue;
pQueryFilter.WhereClause = sParcelID + " IN (" + sHistory + ")";
pCur = pLinesTable.Update(pQueryFilter, false);
IRow pLine = pCur.NextRow();
while (pLine != null)
{
//Check if the cancel button was pressed. If so, stop process
if (m_bShowProgressor)
{
bCont = m_pTrackCancel.Continue();
if (!bCont)
break;
}
iLinesOIDList.Add(pLine.OID);
string sParcHistory = "";
if (ParcelToHistory_DICT.TryGetValue((int)pLine.get_Value(iParcelID), out sParcHistory))
{
string[] sHistoryItems = sParcHistory.Split(',');
if (sHistoryItems[0].Trim() == "")
obj = DBNull.Value;
else
obj = sHistoryItems[0];
pLine.set_Value(iLineSysStartDate, obj);
if (sHistoryItems[1].Trim() == "")
obj = DBNull.Value;
else
obj = sHistoryItems[1];
pLine.set_Value(iLineSysEndDate, obj);
if (sHistoryItems[2].Trim() == "")
obj = DBNull.Value;
else
obj = sHistoryItems[2];
pLine.set_Value(iLineLegalStartDate, obj);
if (sHistoryItems[3].Trim() == "")
obj = DBNull.Value;
else
//.........这里部分代码省略.........
示例11: bAddFields
public static bool bAddFields(ITable pTable, IFields2 pNewFields)
{
// Error Handling
const string functionName = "bAddFields";
try
{
int i;
IField pField;
string sFieldName;
for (i = 0; i < pNewFields.FieldCount; i++)
{
pField = pNewFields.Field[i];
sFieldName = pField.Name;
IFieldEdit pFldEdit;
if (pTable.FindField(sFieldName) < 0 && pField.Type != esriFieldType.esriFieldTypeOID && pField.Type != esriFieldType.esriFieldTypeGUID)
{
pFldEdit = (IFieldEdit)pField;
pFldEdit.Editable_2 = true;
pTable.AddField(pField);
}
}
return true;
}
catch (Exception e)
{
MessageBox.Show(functionName + " :: " + e.Message, "SF10", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
示例12: GetCursorFromCommaSeparatedOIDList
public ICursor GetCursorFromCommaSeparatedOIDList(ITable inTable, string OIDList, string FieldName)
{
try
{
if (OIDList.Trim() == "")
return null;
string sPref; string sSuff;
IDataset pDS = (IDataset)inTable;
IWorkspace pWS = pDS.Workspace;
ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
int iFld=inTable.FindField(FieldName);
string sFldName = inTable.Fields.get_Field(iFld).Name;
//if there is no open parenthesis then add one
if (!OIDList.Trim().StartsWith("("))
{
string sOIDList = ("(" + OIDList).Trim();
}
// remove the last comma if there is one
if ((OIDList.Substring(OIDList.Length - 1, 1)) == ",")
OIDList = OIDList.Substring(0, OIDList.Length - 1);
// add a closing parenthesis if it is missing
if (!OIDList.Trim().EndsWith(")")) OIDList = OIDList + ")";
OIDList = OIDList.Trim();
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = (sPref + sFldName + sSuff).Trim() + " IN " + OIDList;
ICursor pCursor = inTable.Search(pQueryFilter, false);
//Marshal.ReleaseComObject(pQueryFilter);//garbage collection
return pCursor;
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
return null;
}
}
示例13: getSafeFieldName
public string getSafeFieldName(ITable ftrCls, string fldName)
{
string rstOut = fldName;
foreach (string s in new string[] { " ", "\\", "/", "`", "~", "!", ".", ",", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "=", "-" })
{
rstOut = rstOut.Replace(s, "_");
}
while (ftrCls.FindField(rstOut) > -1)
{
rstOut = "_" + rstOut;
}
if (rstOut.Length > 12)
{
IDataset dSet = (IDataset)ftrCls;
if (dSet.Workspace.Type == esriWorkspaceType.esriFileSystemWorkspace)
{
rstOut = rstOut.Substring(0, 10);
}
}
return rstOut;
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:21,代码来源:geodatabaseutility.cs
示例14: createTable
private void createTable()
{
string tblName = "catTbl.dbf";
IWorkspace wks = geoUtil.OpenWorkSpace(rsUtil.TempMosaicDir);
IFields flds = new FieldsClass();
IFieldsEdit fldsE = (IFieldsEdit)flds;
IField fld = new FieldClass();
IFieldEdit fldE = (IFieldEdit)fld;
fldE.Name_2 = "catIndex";
fldE.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
fldsE.AddField(fldE);
IField fld2 = new FieldClass();
IFieldEdit fldE2 = (IFieldEdit)fld2;
fldE2.Name_2 = "XMIN";
fldE2.Type_2 = esriFieldType.esriFieldTypeDouble;
fldsE.AddField(fldE2);
IField fld3 = new FieldClass();
IFieldEdit fldE3 = (IFieldEdit)fld3;
fldE3.Name_2 = "XMAX";
fldE3.Type_2 = esriFieldType.esriFieldTypeDouble;
fldsE.AddField(fldE3);
IField fld4 = new FieldClass();
IFieldEdit fldE4 = (IFieldEdit)fld4;
fldE4.Name_2 = "YMIN";
fldE4.Type_2 = esriFieldType.esriFieldTypeDouble;
fldsE.AddField(fldE4);
IField fld5 = new FieldClass();
IFieldEdit fldE5 = (IFieldEdit)fld5;
fldE5.Name_2 = "YMAX";
fldE5.Type_2 = esriFieldType.esriFieldTypeDouble;
fldsE.AddField(fldE5);
tbl = geoUtil.createTable(wks,tblName,flds);
int catInd = tbl.FindField("catIndex");
int xMinInd = tbl.FindField("XMIN");
int xMaxInd = tbl.FindField("XMAX");
int yMinInd = tbl.FindField("YMIN");
int yMaxInd = tbl.FindField("YMAX");
int cnt = 0;
foreach (IRaster rs in inrs)
{
IRow rw = tbl.CreateRow();
rw.set_Value(catInd, cnt);
IEnvelope ext = ((IRasterProps)rs).Extent;
rw.set_Value(xMinInd, ext.XMin);
rw.set_Value(xMaxInd, ext.XMax);
rw.set_Value(yMinInd, ext.YMin);
rw.set_Value(yMaxInd, ext.YMax);
rw.Store();
cnt++;
}
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:56,代码来源:mergeFunctionArguments.cs
示例15: summarizeRelatedTable
public void summarizeRelatedTable(ITable pTable, ITable rTable, string plinkField, string rlinkField, string[] summaryFlds, string[] groupFlds, rasterUtil.focalType[] stats,string pWhere="", string rWhere="")
{
bool needCatDic = false;
if(stats.Contains(rasterUtil.focalType.ASM)||stats.Contains(rasterUtil.focalType.ENTROPY)||stats.Contains(rasterUtil.focalType.MEDIAN)||stats.Contains(rasterUtil.focalType.MODE)||stats.Contains(rasterUtil.focalType.UNIQUE))needCatDic=true;
HashSet<string> uGroups;
//Console.WriteLine("Summarizing values");
Dictionary<string,Dictionary<string, object[][]>> sumDic = getRelatedSummary(pTable, rTable, plinkField, rlinkField, summaryFlds, groupFlds, needCatDic, pWhere, rWhere, out uGroups);//<link,<group,[6][number of fields to summarize]>
foreach (string s in sumDic.Keys)
{
//Console.WriteLine("ID key:" + s);
}
foreach (string s in uGroups)
{
//Console.WriteLine("Group:" + s);
}
//Console.WriteLine("Updating parent");
int[] newFldNameIndex = new int[summaryFlds.Length * uGroups.Count * (stats.Length+1)];
string[] newFldNameString = new string[summaryFlds.Length * uGroups.Count * (stats.Length+1)];
int IndexCnt = 0;
//int nIndex = pTable.FindField(geoUtil.createField(pTable,"n",esriFieldType.esriFieldTypeDouble,false));
int linkIndex = pTable.FindField(plinkField);
for (int i = 0; i < summaryFlds.Length; i++)
{
string fldNm = summaryFlds[i];
foreach(string k in uGroups)
{
string fldNm2 = fldNm + "_" + k;
string newFldName = geoUtil.createField(pTable, fldNm2 + "_N", esriFieldType.esriFieldTypeInteger, false);
newFldNameString[IndexCnt] = newFldName;
newFldNameIndex[IndexCnt] = pTable.FindField(newFldName);
IndexCnt += 1;
for (int j = 0; j < stats.Length; j++)
{
string fldNm3 = fldNm2 + "_" + stats[j];
newFldName = geoUtil.createField(pTable, fldNm3, esriFieldType.esriFieldTypeDouble, false);
newFldNameString[IndexCnt]=newFldName;
newFldNameIndex[IndexCnt] = pTable.FindField(newFldName);
IndexCnt += 1;
}
}
}
IQueryFilter pQf = new QueryFilterClass();
if (!String.IsNullOrEmpty(pWhere)) pQf.WhereClause = pWhere;
ICursor cur = pTable.Update(pQf, true);
IRow rw = cur.NextRow();
while (rw != null)
{
string lnk = rw.get_Value(linkIndex).ToString();
Dictionary<string,object[][]> d;
if (sumDic.TryGetValue(lnk, out d))
{
//Console.WriteLine("Found dictionary value " + lnk);
object n = 0;
for (int i = 0; i < newFldNameString.Length; i++)
{
string fldNameC = newFldNameString[i];
string[] fldnameArr = fldNameC.Split(new char[] { '_' });
string fld = fldnameArr[0];
string grp = fldnameArr[1];
for (int k = 1; k < groupFlds.Length; k++)
{
grp = grp + "_" + fldnameArr[1 + k];
}
string st = fldnameArr[fldnameArr.Length-1];
object[][] vlFldArr;
if (d.TryGetValue(grp, out vlFldArr))
{
//Console.WriteLine("Found Group value " + grp);
object uVl = 0;
int clIndex = System.Array.IndexOf(summaryFlds, fld);
object[] vlArr = vlFldArr[clIndex];
n = vlArr[0];
if (st != "N")
{
rasterUtil.focalType sType = (rasterUtil.focalType)Enum.Parse(typeof(rasterUtil.focalType), st);
//Console.WriteLine(sType.ToString());
switch (sType)
{
case rasterUtil.focalType.SUM:
uVl = vlArr[1];
break;
case rasterUtil.focalType.MIN:
uVl = vlArr[3];
break;
case rasterUtil.focalType.MAX:
uVl = vlArr[4];
break;
case rasterUtil.focalType.MEAN:
uVl = System.Convert.ToDouble(vlArr[1]) / System.Convert.ToDouble(n);
break;
case rasterUtil.focalType.STD:
uVl = Math.Sqrt((System.Convert.ToDouble(vlArr[2]) - (System.Convert.ToDouble(vlArr[1]) / System.Convert.ToDouble(n))) / (System.Convert.ToDouble(n) - 1));
break;
case rasterUtil.focalType.MODE:
uVl = getMode((Dictionary<string, int>)vlArr[5]);
break;
case rasterUtil.focalType.MEDIAN:
uVl = getMedian((Dictionary<string, int>)vlArr[5]);
break;
case rasterUtil.focalType.VARIANCE:
//.........这里部分代码省略.........