Linq2db Postgis Extensions

.NET Standard 2.0 library with extensions methods for PostGIS geometries methods access with linq2db
Alternatives To Linq2db Postgis Extensions
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Geophp709129233 years ago1December 02, 201475otherPHP
Advanced geometry operations in PHP
Doctrine Postgis1931912 months ago14April 21, 20222mitPHP
Spatial and Geographic Data with PostGIS and Doctrine.
2 days ago19February 16, 20233mitJavaScript
Tool for converting from PostGIS to b3dm tiles
Go.geojson16021982 years ago3May 22, 2019mitGo
Encoding and decoding GeoJSON <-> Go
Geospatial1443713 days ago18December 07, 202181agpl-3.0JavaScript
Odoo and GIS
Postgis_adapter871113 years ago17March 18, 20111otherRuby
RIP : Fork of spatial_adapter to give postgis more love
2 days ago65June 10, 202248mitGo
Simple Features is a pure Go Implementation of the OpenGIS Simple Feature Access Specification
a year ago1apache-2.0C
PostgreSQL extension for the H3 hierarchical geospatial indexing system
Python Postgis63
a year ago4Python
PostGIS helpers for psycopg2 and asyncpg
4 years ago9September 10, 20175otherPython
Alternatives To Linq2db Postgis Extensions
Select To Compare

Alternative Project Comparisons

Linq2db PostGIS Extensions

PostGIS 2.5 PostGIS 3.0 PostGIS 3.1 PostGIS 3.2

.NET Standard 2.0 library with OGC extensions methods on geometry (NpgsqlTypes.PostgisGeometry or NetTopologySuite.Geometries.Geometry) instances, providing strongly typed access to PostGIS functions on server side while using linq2db LINQ to database provider.

Two implementations

Property LinqToDBPostGisNpgsqlTypes LinqToDBPostGisNetTopologySuite
Extending type NpgsqlTypes.PostgisGeometry NetTopologySuite.Geometries.Geometry
Npgsql version 3.x 4.x
PostGIS reference version 1.5 3.0/3.1/3.2
Status Legacy Active
NuGet NuGet
Dependencies linq2db, Npgsql linq2db (>= 3.0.0),
NetTopologySuite (>= 2.0.0),
NetTopologySuite.IO.PostGis (>= 2.0.0),
Npgsql (>= 4.1.0),
Npgsql.NetTopologySuite (>= 4.1.0)


NpgsqlTypes.PostgisGeometry or NetTopologySuite.Geometries.Geometry gets additional methods, similar to Microsoft.SqlServer.Types.SqlGeometry OGC Methods on Geometry Instances or NetTopologySuite plugin for Entity Framework Core for PostgreSQL. These methods will be translated into PostGIS SQL operations, so evaluation will happen on the server side. Calling these methods on client side results in throwing InvalidOperationException. Naming convention follows OGC methods names, starting with ST* prefix.

Using extensions methods inside LINQ expression (Npgsql 4):

using LinqToDBPostGisNetTopologySuite

using (var db = new PostGisTestDataConnection())
    NetTopologySuite.Geometries.Point point = new Point(new Coordinate(1492853, 6895498)) { SRID = 3857 };

    var dms = db.Select(() => GeometryOutput.STAsLatLonText(point));

    var nearestCity = db.Cities
        .OrderBy(c => c.Geometry.STDistance(point))

    var selected = db.Polygons
        .Where(p => p.Geometry.STArea() > 150.0)
        .OrderBy(p => p.Geometry.STDistance(point))

    var stats = db.Polygons
        .Select(c => new
                 Id = c.Id,
                 Name = c.Name,
                 Area = c.Geometry.STArea(),
                 Distance = c.Geometry.STDistance(point),
                 NumPoints = c.Geometry.STNPoints(),
                 Srid = c.Geometry.STSrId(),
                 Wkt = c.Geometry.STAsText(),
[Table("test_geometry", Schema = "public")]
public class PolygonEntity
    public NetTopologySuite.Geometries.Geometry Geometry { get; set; }

[Table("owm_cities", Schema = "public")]
public class CityEntity
    public NetTopologySuite.Geometries.Geometry Geometry { get; set; }

class PostGisTestDataConnection : LinqToDB.Data.DataConnection
    public ITable<PolygonEntity> Polygons { get { return GetTable<PolygonEntity>(); } }
    public ITable<CityEntity> Cities { get { return GetTable<CityEntity>(); } }


Developed using MS Visual Studio 2019. Tested on PostgreSQL version 9.6/11, PostGIS version 2.5/3.0/3.1/3.2. Depends on linq2db, Npgsql.

Getting started with demo application

  • Make sure you have PostgreSQL DBMS with PostGIS extension installed. Execute SELECT PostGIS_Full_Version() query to check PostGIS version.
  • Create new database named "postgistest" (or any other name), add support of spatial features for this database.
  • Execute SQL script Sql\create_tables.sql in this database.
  • Open solution LinqToDBPostGis.sln in Visual Studio.
  • Check database connection string in App.config of all projects.
  • Run application, view table data along with PostGIS functions results in console output.


  • Implement full set of PostGIS methods.
  • Add support for PostGIS geography data type.
  • Test on various versions of PostgreSQL/PostGIS and platforms (including .NET 5).
  • More tests for corner cases.


Popular Geometry Projects
Popular Postgis Projects
Popular Mathematics Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
C Sharp
Spatial Analysis