I was using PostgreSQL with PostGIS and Pgrouting. Recently I needed to install SFCGAL for some extra functions for my PostGIS db. After installing SFCGAL, now I don't know how to update my PostGIS db to bring those SFCGAL functions into my db?


libSFCGAL.so: /usr/local/lib

sfcgal-config: /usr/local/bin

SFCGAL: /usr/local/include

3 Answers 3


Eventually I have figured out how to add SFCGAL functions to a PostGIS db. According to my research, one cannot configure SFCGAL to an existing PostGIS installation.

The best approach for me was to reinstall PostGIS with SFCGAL configuration.

  1. Install SFCGAL. You may need to install prerequisites from terminal like sudo apt-get install cmake libcgal-dev. If anything is missing, terminal will inform you.
  2. Install Postgresql from the terminal like this sudo apt-get install postgresql-server-dev-9.3 postgresql-9.3.
  3. Install PostGIS using postgis-2.1.5dev.tar.gz package and while configuring the package run the command like this sudo ./configure --with-sfcgal=/path/to/the/sfcgal-config/file (mine was /usr/local/bin/sfcgal-config). You may need to specify further paths also like for Proj4, XML2 etc depending upon your system's declared PATH. Terminal will inform you about any missing PATH (but be careful while writing them).
  4. Now my postgis-2.1 folder is in the /usr/share/postgresql/9.3/contrib directory (your may be different). Open the folder and copy the content of sfcgal.sql file.
  5. Finally in your newly created database run the command create extension postgis and then the content you copied from sfcgal.sql file. Necessary new functions should be included in your db.

Hope this will help.


As it is descibed in this answer PostGIS 2.2 now comes with a tool for that:

CREATE EXTENSION postgis_sfcgal
  • Should be the best answer by now!
    – juminet
    May 29, 2018 at 4:47

As far as I know SFCGAL cannot be added to an existing PostGIS installation, if the installation was compiled without configuring for SFCGAL support. Here is some more information on that issue. You will have to compile a SFCGAL enabled version, how to do that for the software versions listed below is described here.

Unbuntu Trusty Tar 14.04 LTS
GEOS 3.5.0
PostgreSQL 9.5
SFCGAL 1.3.0
CGAL 4.7.2 

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.