I have layers in a postgis database that I can load in a MapWindows Control (ocx) using a npgsql connection and creating a shapefile using the geometry field in a Visual Studio .Net 2010 (C#) application, but this is really slow when the layer contains too many features.

I have seen that QGIS loads postgis layers very fast and I want to know if is possible to use the QGIS functionality in any way in a Forms Application using C#, like a DLL or an ocx control. I need to load postgis layers in a display control with legend and be able to change colors, symbology, labels, etc. Also, I need to save any changes in the layer to the postgis database.

Any help will be appreciated.



Unicoletti, thanks for your reply.

I don't see the way to use swig to open a postgis layer and show it in a windows forms. I was wondering if there is any way to encapsullate qgis functionality to do that.

I want to have a control in a form and programatically open a postgis layer on it and, later, manage the properties of that layer, line color, fill color, legends,... Right now I'm using MapWindows ocx but loading postgis layers is really slow, as it's made creating a shapefile and adding shapes to it one by one (using feature data objects).

If you know where to find a complete application example that loads a postgis layer using QGis functionality in c# or even in c++, it would be very appreciated.

Thanks, and sorry for my bad english.

2 Answers 2


Have you tried SharpMap (http://sharpmap.codeplex.com/) or DotSpatial (http://dotspatial.codeplex.com/)? Both are native CLR libraries that can access and render PostGIS data (among others).



While it doesn't mention C# specifically Section 2 of the QGIS Coding and Compilation Guide shows how to embed a Qgis component in a C++ application.

I don't know if C# provides an easy way to wrap C++ code, but if it doesn't you could try wrapping it with swig.


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.