Reverse geocoding

Topics: Algorithms
Apr 23, 2007 at 9:14 PM

How can I make "Reverse Geocoding" on SharpMap?
Thanks for help. =D
May 22, 2009 at 8:55 AM
Edited May 22, 2009 at 8:56 AM

More than two years and no answer. I just hope this topic is forgotten, rather than impossible to implement!

Anyways, the question remains the same. I have all the information I need on shp and dbf files, is it possible to (and if it is, how) make reverse geocoding using SharpMap?

Thanks in advance.

May 22, 2009 at 10:31 AM
Edited May 22, 2009 at 10:34 AM

Hi havitetty, it is certainly not the most efficient way but, you could start by:

taking your input coordinate,

creating a BoundingBox around it, the size of your acceptable margin of error (or in the worst case the size of the dataset),

querying the shapefile by calling ExecuteIntersectionQuery on the shapefile provider and passing in the BoundingBox,

iterating through the results, measuring and minimizing the distance between the result and the input coordinate i.e store the nearest result and overwrite it as nearer ones are found.

if no results were found then you can either increase your bounding box and requery or decide that the result is too inacurate and return null

but personally I would put the dataset in a spatially enabled database where you could minimize the distances within the query.

hth jd

May 22, 2009 at 11:51 AM

Thanks johndiss, unfortunately a spatially enabled database is not an option right now, thus I'll try and follow your directions.


May 25, 2009 at 2:47 PM

Well, hello again.

Your suggestions worked great for me until I began iterating through the FeatureDataSet which contains intersections of the BoundingBox with the shape file features. I am able to iterate and all, but the distance method does not seem to be working. One row in the data set has a geometry of LineString, and I wish to calculate the distance between this linestring and the clicked point, in order to determine which of the returned results is the closest to the desired location. I tried using;


but I keep getting the error "The method or operation is not implemented" on that line of code. Am I doing something wrong?

Thanks in advance.

May 25, 2009 at 5:40 PM
convert to nts geometries (or you can use pythagoras if you are on a planar cs) hth jd
May 26, 2009 at 9:06 AM
Edited May 26, 2009 at 11:32 AM

I know I have asked too many questions but how can I convert to NTS geometries? I am using SharpMap v0.9 and Converters does not include an NTS branch. Neither does 


GisSharpBlog.NetTopologySuite.Geometries.Geometry compareGeometryAsNts =

                    GeometryConverter.ToNTSGeometry(compareGeometry, geometryFactory);

seem to work (even though NTS bins are provided to the project) as GeometryConverter does not seem to be existent. Do i need extra binaries or a newer release?

edit: I have noticed GeometryConverter is a sub of SharpMap.Converters.NTS, so it is just extra information. Still, I have no idea where the NTS subbranch of Converters comes from?..

edit2: Got it. Compiling SharpMap with the proper extensions provided the updated .dll file, which fixes the problem.