POST
|
Thank you, but I think I should have made more clear point on my question. What I need is how to put existing feature class into existing feature dataset, not 'create' new ones. Thank you
... View more
05-15-2014
09:03 AM
|
0
|
0
|
187
|
POST
|
Hello, I have questions regarding to network analysis. I'm using C# .Net. What I gonna to do is 1) Produce line featureclass from some prior steps 2) Convert line featureclass to network dataset 3) Generate OD matrix Step 1 is done. But I don't know how to copy a featureclass to featuredataset, which is required for network dataset. I searched web, but there are only 'suggestions' like about using IDataset.adddata without any sample code. Also, I tried to designate feature dataset as an output location of geogprocessing, but failed. If there is a way to designate feature dataset as output location of geogprocessing, it will be also fine. For example, code on the bellow is convert layer (polygon featureclass) to line featureclass. Is there any way to make output on the featuredataset at the same workspace?? I tried but failed. fc2Line.in_features = layer; fc2Line.out_feature_class = "grid_Line"; gp.Execute(fc2Line, null); Thank you.
... View more
05-14-2014
12:35 PM
|
0
|
3
|
501
|
POST
|
Hi, How can I insert (or copy, move) features from one featureclass to another with original attributes? I have two featureclasses, and both of them have same fields. I want to select part of Featureclass A, then move those selected features to FeatureClass B, with their attributes. I can do move operations, but it loose all attributes. How can I do this? Thank you Insu
... View more
04-15-2013
03:15 PM
|
0
|
3
|
571
|
POST
|
Or you can use Disjoint method to double check. Another thing seems confusing is fcInsideBarriers a feature class or geometry? IRelationalOperator only works with geometries. I tried IRelationalOperator again.. but it was failed. Does IRelationalOperator compatible with IGeometryBag?
IGeometryBag gbTotalConvexPathSplit = fcUtils.getGeoBag(fcTotalConvexPathSplit);
IRelationalOperator relOper1 = (IRelationalOperator)gbTotalConvexPathSplit;
Console.WriteLine(relOper1.Crosses(gbInsideBarriers));
if (!relOper1.Crosses(gbInsideBarriers))
{
Console.WriteLine("break");
break;
}
I tried like above... gbTotalConvexPathSplit and gbTotalConvexPathSplit is IGeometryBag object. Even though they are crossed each other, relOper1.Crosses(gbInsideBarriers) return fales at the very first iteration.
... View more
03-14-2013
11:31 AM
|
0
|
0
|
434
|
POST
|
Or you can use Disjoint method to double check. Another thing seems confusing is fcInsideBarriers a feature class or geometry? IRelationalOperator only works with geometries. hi, I think that part is my mistake. fcIinsideBarrier is featureclass. But strange thing is, I also tried same job with ISpatialCursor
IGeometryBag gbTotalConvexPathSplit = fcUtils.getGeoBag(fcTotalConvexPathSplit);
ISpatialFilter sFilter101 = new SpatialFilterClass();
sFilter101.Geometry = gbTotalConvexPathSplit;
sFilter101.GeometryField = fcInsideBarriers.ShapeFieldName;
sFilter101.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
Console.WriteLine(fcInsideBarriers.FeatureCount(sFilter101));
if (fcInsideBarriers.FeatureCount(sFilter101) == 0)
{
Console.WriteLine("Break");
Console.ReadKey();
break;
} but it also made error. Mostly, it worked fine. But after repeating iterations, suddenly spatialcursor said there was no crossing, though actually there were many crossings. I will try corrected IRelationalOperator. Thank you
... View more
03-14-2013
09:50 AM
|
0
|
0
|
434
|
POST
|
Hi, No polylines are not contained by any polygon. It cannot be contained, because prior processes. Also, fcTotalcovnexPathSplit contains large number of polylines. All of polylines intersected (with boundaries of polygons) or crossed. I confirm that in ArcGIS manually.
... View more
03-14-2013
09:16 AM
|
0
|
0
|
434
|
POST
|
Hello, I have a serious problem with spatial query in ArcObject.
IRelationalOperator relOperInsideBarriers = (IRelationalOperator) fcInsideBarriers
IGeometryBag gbTotalConvexPathSplit = fcUtils.getGeoBag(fcTotalConvexPathSplit);
if (relOperInsideBarriers.Crosses(gbTotalConvexPathSplit) == false)
{
Console.WriteLine("Break");
break;
}
Code is simple. I update featureclass "fcTotalConvexPathSplit" before this codeblck using other operations, then check 'crossing' with fcInsideBarriers. fcTotalConvexPathSplit is line, and fcInsideBarriers is polygon. "relOperInsideBarriers.Crosses(gbTotalConvexPathSplit)" is supposed to return false there is no line in fcTotalConvexPathSplit crosses fcInsideBarriers, right? But, it return false when there are many number of crossings. I tried to simplify it, like below
IGeometryBag gbTotalConvexPathSplit = fcUtils.getGeoBag(fcTotalConvexPathSplit);
ITopologicalOperator pTopOp = gbTotalConvexPathSplit as ITopologicalOperator;
pTopOp.Simplify();
IGeometry igTopo = pTopOp as IGeometry;
if (relOperInsideBarriers.Crosses(igTopo) == false)
{
Console.WriteLine("Break");
break;
}
But result was same. It makes error. I also tried to use ISpatialFilter, but it made similar error, though it sometimes could produce right result, but otherwise couldn't. What's going on here. I cannot figure out what the problem is... Thank you
... View more
03-13-2013
01:46 PM
|
0
|
6
|
744
|
POST
|
Are you trying to close ArcMap or just your Add-In? Is your Add-In just a form? I'm trying to close just Add-In. My add-in has a form, and after get user input using form, form is closed (which has no problem), then certain codes are running. What I try to do is stop running all codes and return to ArcMap. Just like cancel button in ordinary ArcMap tools.
... View more
12-11-2012
10:20 AM
|
0
|
0
|
205
|
POST
|
Hi, I'm developing ArcMap Add-In. But I have a problem in closing program. When all processes are completed normally, it's OK. But when I closing window using 'Application.Exit()' function, (I assigned it 'Cancel' button) ArcMap just crashed... What is the problem? Am I miss something? Insu
... View more
12-10-2012
06:14 PM
|
0
|
2
|
470
|
POST
|
Hi guys I've got a problem with spatial query. I generate IGeometry igPairLine and compare it a map boundary (IGeometrybag gbBaseMap) using IRelationalOperator. The purpose is checking whether a line is within the map boundary or not. I repeat this process for thousands of thousands lines (literally). But 60 of them were wrong. My code determined they are within the map boundary, but actually not. I don't know why exact same code make such error for certain cases. Does anybody know why? Thank you ISpatialReference sRef; ifMerged = fcMerged.GetFeature(1); IPoint pt = new PointClass(); pt = (IPoint)ifMerged.ShapeCopy; sRef = pt.SpatialReference; IPoint fromPoint = new PointClass(); IPoint toPoint = new PointClass(); fromPoint = pcTempPair.get_Point(0); toPoint = pcTempPair.get_Point(1); IPolyline5 ipPairLine = new PolylineClass(); ipPairLine.ToPoint = toPoint; ipPairLine.FromPoint = fromPoint; ipPairLine.Project(sRef); IGeometry igPairLine = (IGeometry)ipPairLine; IRelationalOperator relOperatore = (IRelationalOperator)gbBaseMap; Boolean contain = relOperatore.Contains(igPairLine);
... View more
11-15-2012
09:06 PM
|
0
|
2
|
810
|
POST
|
Hi all I'm developing add-in for ArcMap using C#. I find a way to extract vertices of polyline. With polygon, after convert polygon featureclass to Ipolygon, I can extract vertices of polygon. But I don't know how to do it with polyline. Currently, I'm using Feature Vertices to Point tool in ArcToolbox. But I have to repeat that operation for thousands of polylines, computation time is really matter. Is there any faster way to extract vertices of polyline? Thank you
... View more
11-14-2012
12:10 PM
|
0
|
1
|
904
|
POST
|
Hi, I want to create polygon from polygon and polyline. Just like this. I want to create polygon which is filled gap between polygon and polyline. [ATTACH=CONFIG]19208[/ATTACH] In ArcMap, I used 'feature to polygon' tool for that. But it did not work properly in C# Add-in. I repeat that operation with several hundred lines and same polygon. The very first operation works well. But in the second iteration, "feature to polygon" tool just make error. I set on 'overwright' for geoprocessing. And I erase prior result before start next iteration. erasing operation goes well. Is there any other way do same job? Actually, 'feature to polygon' tool spends 1 sec for operation. But I have to repeat same operation for hundreds of thousand lines, I need faster way to do it. Or anyone has idea what's the problem?
... View more
11-11-2012
12:15 PM
|
0
|
0
|
719
|
POST
|
Hello, I have a problem with geoprocessing. I want to input multiple featureclasses as input for geoprocessing (in this case, Feature to Polygon tool). I tried IGpValueTableObject, but it did not work at all. How can I input multiple IFeatureClass objects? Thank you IGpValueTableObject vt = new GpValueTableObjectClass(); vt.SetColumns(2); vt.SetColumns(2); object weight; weight = 1 as object; object obj1 = fcBoundary; vt.AddRow(ref obj1); vt.SetValue(0, 1, ref weight); object obj2 = fcPairLine; vt.AddRow(ref obj2); vt.SetValue(1, 1, ref weight); parameters = new VarArrayClass(); parameters.Add(vt); parameters.Add("polyMerged"); gp.Execute("FeatureToPolygon_management", parameters, null);
... View more
11-08-2012
06:50 PM
|
0
|
1
|
365
|
POST
|
Not sure where to begin. You have a lot to learn about writing good code. In general it is poor design to put a large script inside the onclick event of a button. You make use of some try blocks which is good but maybe just wrap the whole thing in a try block and report the error in a message box so you know what the problem is. It doesn't look like runConvexPath() is ever called. Therefore you have never created the geoprocessor object before you start using it in your onclick event. Don't instantiate these objects in runConvexPath(), just create them where you need them. Hi. Thank you for comment. Originally, I wrote code as separated classes. But it crashed. When I tried to same code in current shape, strangely it worked. I don't know why. It supposed to be run well, because I implemented simple one geoprocessing, and that code just copy-paste from sample code! This is first time I ever use C# .net, so I don't know much. So I tried to follow examples, but it seems to me much of them not work well. Now I can catch errors with try blocks (Thanks!). But I still don't get it why does it make error.... Original code was implemented in simple console application for my research. Now I want to implement it as Add-in, but my code does not work at all in Add-In project.
... View more
11-08-2012
11:27 AM
|
0
|
0
|
304
|
POST
|
Hello, I implement following code to make add-in for ArcMap. After user inputs from 'newform' window, geoprocessors do their job. But when I run this code, ArcMap just crashed without any message or report. I tried to debug it, but it's just same. Crashed. I checked debug setting, it was fine, exactly same as ESRI's instruction on web resource. I will add more code after this, but crashing without any report like this, I cannot do programing? It would be helpful if I know 1) why does current code make crash? 2) how can I debug add-in and find what is a problem, not just crash without any clue? Thanks
namespace Convexpath_mk2
{
public class runConvexPath : ESRI.ArcGIS.Desktop.AddIns.Button
{
IGeoProcessor2 gp;
IGeoProcessorResult result;
IVariantArray parameters;
struct pair
{
//definition of pair data type
}
struct coords
{
//definition of coords data type
}
public runConvexPath()
{
gp = new GeoProcessorClass();
parameters = new VarArrayClass();
}
protected override void OnClick()
{
ConvexPathForm newForm = new ConvexPathForm();
newForm.Text = "Test";
newForm.ShowDialog();
Dictionary<string, string> fcDict = new Dictionary<string, string>();
fcDict = newForm.caDi();
string path = fcDict["path"];
gp.SetEnvironmentValue("workspace", path);
gp.OverwriteOutput = true;
gp.AddOutputsToMap = false;
List<string> oriList = new List<string>();
List<string> desList = new List<string>();
Dictionary<pair, pairData> pairDict = new Dictionary<pair, pairData>();
List<pair> pairList = new List<pair>();
Dictionary<string, string> belongDict = new Dictionary<string,string>();;
FCUtils fcUtils = new FCUtils();
string idxOrigin = fcDict["idxOrigin"];
string idxDestine = fcDict["idxDestine"];
//Making Map boundary (polyline)
string strBoundaryline = "boundaryline";
parameters = new VarArrayClass();
parameters.Add(fcDict["fcBoundary"]);
parameters.Add(strBoundaryline);
gp.Execute("FeatureToLine_management", parameters, null);
//Making Barrier boundary (polyline)
string strBarrierline = "barrierline";
parameters = new VarArrayClass();
parameters.Add(fcDict["fcInsideBarriers"]);
parameters.Add(strBarrierline);
gp.Execute("FeatureToLine_management", parameters, null);
//Making boundary vertices (point)
string strBoundaryVertices = "boundaryVertices";
parameters = new VarArrayClass();
parameters.Add(fcDict["fcBoundary"]);
parameters.Add(strBoundaryVertices);
gp.Execute("FeatureVerticesToPoints_management", parameters, null);
//Making fcMerged
string strMerged = "merged";
parameters = new VarArrayClass();
List <string> merged = new List<string>();
merged.Add(fcDict["fcOrigin"]);
merged.Add(fcDict["fcDestine"]);
parameters.Add(merged);
parameters.Add(strMerged);
gp.Execute("Merge_management", parameters, null);
//Making fcFillBoundary
string strFillBoundary = "FillBoundary";
parameters = new VarArrayClass();
parameters.Add(fcDict["fcBoundary"]);
parameters.Add(strFillBoundary);
gp.Execute("EliminatePolygonPart_management", parameters, null);
//Making index field for boundary vertices
try
{
parameters = new VarArrayClass();
parameters.Add(strBoundaryVertices);
parameters.Add("id_f");
parameters.Add("SHORT");
gp.Execute("AddField_management", parameters, null);
}
catch (COMException comExc)
{
string errMsg = comExc.Message;
}
parameters = new VarArrayClass();
parameters.Add(strBoundaryVertices);
parameters.Add("id_f");
parameters.Add("[OBJECTID]");
parameters.Add("VB");
gp.Execute("CalculateField_management", parameters, null);
IGPUtilities2 gpUtils = new GPUtilitiesClass();
gpUtils.Workspace = path;
IFeatureClass fcOrigin = gpUtils.OpenFeatureClassFromString(fcDict["fcOrigin"]);
IFeatureClass fcDestine = gpUtils.OpenFeatureClassFromString(fcDict["fcDestine"]);
IFeatureClass fcBoundary = gpUtils.OpenFeatureClassFromString(fcDict["fcBoundary"]);
IFeatureClass fcBarrier = gpUtils.OpenFeatureClassFromString(fcDict["fcBarrier"]);
IFeatureClass fcBoundaryLine = gpUtils.OpenFeatureClassFromString(strBoundaryline);
IFeatureClass fcBarrierLine = gpUtils.OpenFeatureClassFromString(strBarrierline);
IFeatureClass fcBoundaryVertices = gpUtils.OpenFeatureClassFromString(strBoundaryVertices);
IFeatureClass fcMerged = gpUtils.OpenFeatureClassFromString(strMerged);
IFeatureCursor curBoundaryVertices;
IFeature ifBoundaryVertices = null;
IFeatureCursor oriCursor;
IFeatureCursor desCursor;
string oid;
IFeature feature = null;
oriCursor = fcOrigin.Search(null, false);
int idFcOrigin_id_f = fcOrigin.Fields.FindField(idxOrigin);
try
{
while ((feature = oriCursor.NextFeature()) != null)
{
oid = (string)feature.get_Value(idFcOrigin_id_f);
oriList.Add(oid);
belongDict[oid] = "orgin";
}
Marshal.ReleaseComObject(oriCursor);
}
catch (COMException comExc)
{
string errMsg = comExc.Message;
}
desCursor = fcDestine.Search(null, false);
try
{
while ((feature = desCursor.NextFeature()) != null)
{
oid = (string)feature.get_Value((feature.Fields.FindField(idxDestine)));
desList.Add(oid);
belongDict[oid] = "destine";
}
Marshal.ReleaseComObject(desCursor);
}
catch (COMException comExc)
{
string errMsg = comExc.Message;
}
foreach (string i in oriList)
{
foreach (string j in desList)
{
pair pKey = new pair(i, j);
pairList.Add(pKey);
}
}
List<string> lines = new List<string>();
int total_edges = 0;
long start_clip = DateTime.Now.Ticks;
foreach (pair i in pairList)
{
double euDistance = 0;
IGeometry geo = new MultipointClass();
IPointCollection5 pcTempPair = geo as IPointCollection5;
ISpatialFilter sFilter1 = new SpatialFilterClass();
sFilter1.GeometryField = fcMerged.ShapeFieldName;
sFilter1.WhereClause = "id_f = '" + i.getOri + "' OR id_f = '" + i.getDes + "'";
IFeatureCursor curMerged3 = fcMerged.Search(sFilter1, false);
IFeature ifMerged = null;
while ((ifMerged = curMerged3.NextFeature()) != null)
{
IPoint ptIn = new PointClass();
ptIn = (IPoint)ifMerged.ShapeCopy;
pcTempPair.AddPoint(ptIn);
}
}
}
protected override void OnUpdate()
{
Enabled = ArcMap.Application != null;
}
}
}
... View more
11-08-2012
10:13 AM
|
0
|
2
|
522
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|