2

I have am trying to add functionality to allow users to find points that are within a buffer distance inside or outside the parameter of a polygon. The map is in IProjectedCoordinateSystem so to my understanding the the ITopologicalOperator.Buffer is in degree units. I want to be able to use the users provided buffer in meters.

I figured I could project the polygon to another coordinate system, apply the buffer in meters and then convert back. This does not seem to be working correctly. Is this the correct or only way to get a buffer in meters when working in degrees?

private static IGeometry AddBufferToSearchFromGeometry([NotNull] IGeometry originalShape, double buffererSizeInMeters)
{
    IGeometry projectedShape = (originalShape as IClone).Clone() as IGeometry; 
    ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
    IProjectedCoordinateSystem projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_11N); 
    projectedCoordinateSystem.SetFalseOriginAndUnits(-180, -90, 1000000);
    projectedShape.Project(projectedCoordinateSystem);
    IGeometry5 bufferedGeometry = (projectedShape as ITopologicalOperator).Buffer(buffererSizeInMeters) as IGeometry5;
    bufferedGeometry.Project5(originalShape.SpatialReference, 0);

    return bufferedGeometry;
    }
  • 2
    There's a lot wrong here. If the coordinate system is projected, the buffer distance by default) should be in the same units. Depending on version, you might be able to create a geodesic buffer directly on a geometry using a GCS. Spatial Ref params, false origin/unit are giving lat/lon based values. See this for an example. – mkennedy May 25 '16 at 19:06
  • They don't make it very easy to add a buffer in linear units to a polygon to filter for some points. I would have thought this was a somewhat common thing. I don't think using a GCS (Geometric Conversion Service?) would be be feasible as it will not always have an internet connection. I guess I don't really understand this. – scott lafoy May 25 '16 at 20:31
  • GCS=geographic coordinate system (in degrees). If the map's in a projected cs (pcs), you should probably build the buffer the same coordinate system, then you don't need to project at all. If you need to also handle the case where the map is using a gcs, depending on version, you may need to project the geometry to a pcs, or you may be able to create a "geodesic-based" buffer. – mkennedy May 25 '16 at 21:55
  • It's been best practice to avoid using a {-180,-90} origin for GCS data since the SDE 1.4 Beta training class was held in 1995. Use {-400,-400} with a scale of 1e+06 or 1e+07, and this error disappears (there's still an issue with the methodology, but you'll be able to make forward progress). – Vince May 26 '16 at 2:08
  • I see what you're doing and it should work, is your originalShape.SpatialReference compatible with NAD1983UTM_11N? I've seen this fall over due to needing a known transformation in the projection, if this is the case you want to use IGeometry5.ProjectEx with an IGeoTransformation. I usually use ISpatialReferenceFactory2.CreateSpatialReference with a SRID code (yours is 26911 I think), I find it easier than specifying a bunch of parameters for a known spatial reference. – Michael Stimson May 27 '16 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.