Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've written some code to intersect features of one layer with another's, but one layer has polygons (the squares in the image) and the other has circles (not filled).

The problem is that I'm using IPointCollection interface to get the features' points and I'm only getting the border vertices of the squares

enter image description here

I tried getting the convex hull of one single feature but I failed because to use the intersect method I still have to convert to a IPointCollection

Here's the code I am using

// Get first layer's points
IGeometry multipoint = new MultipointClass();
multipoint.SpatialReference = m_firstLayerFirstfeatureIGeometry.SpatialReference;
IPointCollection multipointPoints = (IPointCollection)multipoint;

// Cycle all features of first layer and add them to the collection
foreach (DataRow m_dr in m_firstLayerfeatureGraphics.Rows)
{
    // Takes this feature's geometry
    ESRI.ArcGIS.ADF.Web.Geometry.Geometry adfFeature =
        m_firstLayerfeatureGraphics.GeometryFromRow(m_dr) as ESRI.ArcGIS.ADF.Web.Geometry.Geometry;
    // convert to a igeometry object
    ESRI.ArcGIS.Geometry.IGeometry m_tempfeatureIGeometry =
    ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Local.Converter.ToIGeometry(adfFeature, ctx);

    IPointCollection mtempfet = (IPointCollection)m_tempfeatureIGeometry;

    //Add copies of the polyline vertices to the multipoint.
    multipointPoints.AddPointCollection((IPointCollection)mtempfet); 
}


ESRI.ArcGIS.Geometry.ITopologicalOperator6 mtopo1 = (ESRI.ArcGIS.Geometry.ITopologicalOperator6)multipointPoints;


// Get second layer's points
IGeometry multipoint2 = new MultipointClass();
multipoint2.SpatialReference = m_masterLayerFirstfeatureIGeometry.SpatialReference;
IPointCollection multipointPoints2 = (IPointCollection)multipoint2;

// Cycle all features of first layer and add them to the collection
foreach (DataRow m_dr in m_masterLayerfeatureGraphics.Rows)
{
    // Takes this feature's geometry
    ESRI.ArcGIS.ADF.Web.Geometry.Geometry adfFeature =
        m_firstLayerfeatureGraphics.GeometryFromRow(m_dr) as ESRI.ArcGIS.ADF.Web.Geometry.Geometry;
    // convert to a igeometry object
    ESRI.ArcGIS.Geometry.IGeometry m_tempfeatureIGeometry =
    ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Local.Converter.ToIGeometry(adfFeature, ctx);

    IPointCollection mtempfet = (IPointCollection)m_tempfeatureIGeometry;

    //Add copies of the polyline vertices to the multipoint.
    multipointPoints2.AddPointCollection(mtempfet);
}


ESRI.ArcGIS.Geometry.ITopologicalOperator6 mtopo2 = (ESRI.ArcGIS.Geometry.ITopologicalOperator6)multipointPoints2;



// INTERSECTION
ESRI.ArcGIS.Geometry.IGeometry mpointCol = (ESRI.ArcGIS.Geometry.IGeometry)mtopo2.IntersectEx((IGeometry)mtopo1, false, esriGeometryDimension.esriGeometryNoDimension);


// Draw the result
DrawIGeometryOnMap(m_Map, mpointCol);
share|improve this question

1 Answer 1

up vote 1 down vote accepted

Aggregate the points collection to a polygon

share|improve this answer
    
How? There isn't a IPolygonCollection, the IPointCollection is the base interface for points, polygons and polylines –  Marco A. Aug 11 '11 at 12:03
    
But you pass points into be aggregated into a polygon. I am sure there's an ArcObjects function/class of this. You put in points, you get out polygons. –  Hairy Aug 11 '11 at 12:42
    
I really can't find that, I'm looking at Polygon class which is built with "rings"... but why rings? Wasn't easier to construct it from points? The "Convex hull" isn't working too –  Marco A. Aug 11 '11 at 13:39
    
I think it is dissolve perhaps? help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… –  Hairy Aug 11 '11 at 14:28
    
Take a look at this example of how to build rings and produce a polygon from points. –  mrohlf Aug 11 '11 at 14:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.