I have a shapefile generated by the ESRI product suite. I do not have any ESRI products and my budget does not support their purchase. Aside from fiscal issues, there may be technical limitations with deploying ESRI products but that's a moot point since we have no money.

Using .NET and, if necessary, open source libraries, how can I read my shape file data and return the polygon that contains a latitude and longitude coordinate? I see this being built as service code and given a coordinate, it returns the polygon. Conceptually not too difficult but I'm not sure which libraries out there will help with this.


edit #1 - I'd settle for returning the polygon's ID or description or some other string property. If I want more info, I will fetch that using the polygon's ID or name or ???

edit #2 - The solution should be something I can call from a service. For example, a library I can call from my .NET code would work just fine. An application that must be installed and data entered through its UI will not work since my application will be deployed.


2 Answers 2


SpatiaLite is one of the many potential solutions. It probably depends a bit on whether the shapefile you are working on is dynamic or its always the same file (or one of a few files of static content), but loading the shapefile using VirtualShape virtual table extension or the ImportSHP() SQL function will make it available in SpatiaLite.

Then you can use any of the SpatiaLite spatial functions such as ST_Contains or ST_Intersects (depend on what you mean by "contains" - for example, what happens if the point is on the border?) to select the point including some or all of the attributes.

Depending on the number of rows, you may want to use a spatial index to assist with the search, although a full table scan isn't usually a problem for up to a few thousand polygons. Note: SpatiaLite requires the index to be defined, and to be explicitly included in each search operation. It is not enough to just create the index.

Use from C# is no problem - just use System.Data.SQLite and load the DLL / shared library as an extension.


There are a ton of free software out there that will allow you to export the polygon and see the lat long coordinates of it.

Your question was answered previously How to export Polygons to CSV with coordinates?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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