This project has moved and is read-only. For the latest updates, please go here.

Coordinates from a shapefile

Topics: General Topics
Mar 11, 2007 at 10:10 PM
Hi everybody,

Does anybody know how I can access the coordinates from a shapefile for examble to to get the nearest arc to a point?

Thank you very much in advance for your help!
Mar 13, 2007 at 7:25 PM
Hi Madison,

I don't quite understand - do you want the coordinates of the extents of a shapefile (the full bounds of the all the shapes in the shapefile in the coordinate system of the shapefile) or the coordinates of a shape in the shapefile?

Also, determining the nearest spatial geometry (arc) to another geometry (point) needs to use a spatial relational model which is not yet part of SharpMap. You'll need to use something like NTS for this.
Mar 16, 2007 at 2:19 PM
Hi codekaizen,

thank you very much for your tip. I took it to heart and had a look at NTS. the result is the following code, which returns the coordinate on a linestring (myPseudoCoord), which is closest do a certain point, I got by GPS (currentX, currentY). It's sort of a map matching algorithm for a routing application.

Dim currentX = koordGK.getX_GKoord()
Dim currentY = koordGK.getY_GKoord()
Dim i As UInteger = 0

Dim myShape As SharpMap.Data.Providers.ShapeFile = New SharpMap.Data.Providers.ShapeFile(STRROADSHAPEPATH)
Dim iFeature As UInteger = myShape.GetFeatureCount()
Dim currentPoint As New SharpMap.Geometries.Point(currentX, currentY)
Dim myPt As TerraNova.NetTopologySuite.Geometries.Geometry = SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(currentPoint, New TerraNova.NetTopologySuite.Geometries.GeometryFactory())
Dim myArcs As TerraNova.NetTopologySuite.Geometries.Geometry = SharpMap.Converters.NTS.GeometryConverter.ToNTSGeometry(myShape.GetFeature(i).Geometry, New TerraNova.NetTopologySuite.Geometries.GeometryFactory())
Dim myPseudoCoord As TerraNova.NetTopologySuite.Geometries.Coordinate()
myPseudoCoord = TerraNova.NetTopologySuite.Operation.Distance.DistanceOp.ClosestPoints(myPt, myArcs)


Mar 17, 2007 at 5:09 PM

Looking at napespace names, you're using a old version of NTS.
The latest release is here:
Mar 19, 2007 at 5:01 PM
I'm using the Pocket PC version
That's probably why it's an older version.