A .NET Standard library (works in .Net core, .Net 4.6.1 and Xamarin projects) that provides forward and reverse geocoding of locations using the OpenCage Geocoder geocoder. The OpenCage geocoding API supports the entire world and is based on various open datasources like OpenStreetMap.
OpenCage Data Geocoding Library for .Net Standard alternatives and similar packages
Based on the "Gis" category.
Alternatively, view OpenCage Data Geocoding Library for .Net Standard alternatives based on common mentions on social networks and blogs.
GMap.NET - Great Maps for Windows Forms & Presentation
A .NET GIS solution that is fast and reliable for the .NET platform
An easy-to-use mapping library for use in web and desktop applications
.Net library for GeoJSON types & corresponding Json.Net (de)serializers
C# library to work with OpenStreetMap (OSM) data. Provides reading, writing and route-planning for OSM data.
Easily parse or convert coordinate formats and calculate location based solar/lunar information.
.Net library for Digital Elevation Models, allows 3D terrain generation in glTF / STL format.
Digital Elevation model library in C#. GeoTiff file parsing and DEM querying.
Easy to use, simple, offline (reverse) geocoding using GeoNames.org.
A library to create GeoJSON from Entity Framework Spatial Data or Well-Known Text (WKT) inputs.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of OpenCage Data Geocoding Library for .Net Standard or a related project?
OpenCage Data Geocoding Library for .Net StandardvsGMap.NET
OpenCage Data Geocoding Library for .Net StandardvsNetTopologySuite
OpenCage Data Geocoding Library for .Net StandardvsSharpMap
OpenCage Data Geocoding Library for .Net StandardvsOsmSharp
OpenCage Data Geocoding Library for .Net StandardvsNGeoNames
OpenCage Data Geocoding Library for .Net Standard
Dependencies and Requirements
- .NET Standard 2.0
- ServiceStack.Text.Core ver 1.0.44 (added via Nuget)
- OpenCageGeocoder key - get yours FREE
Reference the library using Nuget
Create an instance of the geocoder library, passing a valid OpenCage Data Geocoder API key as a parameter to the geocoder library's constructor:
var gc = new Geocoder("YOUR_KEY");
Pass a string containing the query or address to be geocoded to the library's
var result = gc.Geocode("82 Clerkenwell Road, London");
You will get a strongly typed GeocoderResponse object returned.
There are many parameters for language, country, bounds and more see https://opencagedata.com/api for explanations of them all or read the documentation provided for each parameter in Visual Studio.
Putting all of this together as a console app, a complete sample with a basic and advanced usage would look like this:
var gc = new Geocoder("YOURKEYHERE"); // simplest example with no optional parameters var result = gc.Geocode("newcastle"); // example with lots of optional parameters var result2 = gc.Geocode("newcastle", countrycode: "gb", limit: 2, minConfidence: 6, language: "en", abbrv: true, noAnnotations:true, noRecord: true, addRequest: true);
Usage (Reverse Geocoding)
Reverse geocoding is almost identical but you pass in a latitude and longitude pair:
var gc = new Geocoder("YOUR_KEY"); var reserveresult = gc.ReverseGeocode(51.4277844, -0.3336517); reserveresult.PrintDump(); // ServiceStack human readable object dump to console
There are many parameters for language, limiting results and more see https://opencagedata.com/api for explanations of them all or read the documentation provided for each parameter in Visual Studio.
Further examples of a .Net Core and .Net 4.6.1 console application are available within the solution as projects 'GeocoderDemo.Net461' and 'GeocoderDemo.NetCore'.
Any errors that the geocoding service returns will be found in the RequestStatus property of the GeocoderResponse object. RequestStatus contains the standard HTTP error status code as the Code property and a more helpful error message in the Message property.
Before starting to use the OpenCage geocoder in your projects we advice you read the Best Practices document to ensure you get the best results possible.
Two error codes are used when any rate limiting has come into effect:
- 402 - 'Valid request but quota exceeded (payment required)'
- 429 - 'Too many requests (too quickly, rate limiting)'
For more about the rate limits read the OpenCage Geocoder API Documentation.
Older versions for pre .Net 4.6.1
The previous release of this library was not targeted at .Net Standard but at .Net 4.6. The nuget package for this is still available at https://www.nuget.org/packages/OpenCageGeocoder/ but will not be maintained so we recommend using this new library and updating to a supported .Net version.