ThinkGeo.com    |     Documentation    |     Premium Support

Line to Polygon Using Buffer

I am attempting to create a buffer around a line feature. I can successfully do that, however when I go to measure the new polygon starting from where the line was (which should be the “distance” in length), it is ~2.5 times as wide as it should be.

Here is the code for creating the buffer:

Dim drawnFeature As Feature = WpfMap_Main.TrackOverlay.TrackShapeLayer.InternalFeatures(WpfMap_Main.TrackOverlay.TrackShapeLayer.InternalFeatures.Count - 1).CloneDeep(ReturningColumnsType.AllColumns)

Dim lbs As LineBaseShape = DirectCast(drawnFeature.GetShape(), LineBaseShape)

Dim bs As MultipolygonShape = lbs.Buffer(100, 50, BufferCapType.Butt, GeographyUnit.Feet, DistanceUnit.Feet)

Dim newFeature As New Feature(bs, WpfMap_Main.TrackOverlay.TrackShapeLayer.InternalFeatures.Item(0).ColumnValues)

This will create a polygon that is over 400 feet wide when it should be exactly 200.

Here is how we determine the length:

Public Shared Function MeasureLength(ByVal linearShape As LineBaseShape, ByVal returnLinearUnits As DistanceUnit) As Double

m_MapProjection.m_LayerProjection.Open()

Return DirectCast(m_MapProjection.m_LayerProjection.ConvertToInternalProjection(linearShape), LineBaseShape).GetLength(m_MapProjection.m_InputProjectionUnit, returnLinearUnits).ToString(“F2”)

End Function

The internl projection of m_MapProjection.m_LayerProjection = ManagedProj4Projection.GetGoogleMapParametersString

The internal projection that the buffered feature goes into is:

PROJCS[“NAD_1983_HARN_UTM_Zone_18N”,GEOGCS[“GCS_North_American_1983_HARN”,DATUM[“D_North_American_1983_HARN”,SPHEROID[“GRS_1980”,6378137.0,298.257222101]],PRIMEM[“Greenwich”,0.0],UNIT[“Degree”,0.0174532925199433]],PROJECTION[“Transverse_Mercator”],PARAMETER[“False_Easting”,1640416.666666667],PARAMETER[“False_Northing”,0.0],PARAMETER[“Central_Meridian”,-75.0],PARAMETER[“Scale_Factor”,0.9996],PARAMETER[“Latitude_Of_Origin”,0.0],UNIT[“Foot_US”,0.3048006096012192]]

I am not sure if the projections make a difference.

If I remove the conversion to internal projection from the above function return statement, the numbers match up, but the shape still is too large based on the scale we use.

Here is the code for the scale bar:

Dim scaleBar As New ScaleBarAdornmentLayer()

scaleBar.Location = AdornmentLocation.LowerLeft

'scaleBar.YOffsetInPixel = -40.0F

scaleBar.UnitFamily = UnitSystem.Imperial

scaleBar.HasMask = True

scaleBar.MaskBrush = New GeoSolidBrush(GeoColor.FromArgb(150, GeoColor.StandardColors.White))

scaleBar.MaskContour = New GeoPen(GeoColor.StandardColors.Transparent)

m_CurrentMapInstance.AdornmentOverlay.Layers.Add(“ScaleBarAdornmentLayer”, scaleBar)

Any help in this matter is much appreciated.

Hi Joshua,

We will reply you in your ticket.

Regards,

Don