Table of Contents [expand]
Last updated January 28, 2026
The PostGIS module adds support for geographic objects to the PostgreSQL object-relational database. In effect, PostGIS “spatially enables” the PostgreSQL server, allowing you to use it as a backend spatial database for geographic information systems (GIS). PostGIS is available on all Heroku Postgres plans. Heroku currently supports PostGIS v3.
Provisioning
You can add PostGIS like any other extension, as long as your database meets the requirements earlier.
To install PostGIS in an existing Heroku Postgres database, open a psql session, and run CREATE EXTENSION postgis;:
$ heroku pg:psql DATABASE_URL -a example-app
--> Connecting to postgresql-octagonal-12345
psql (13.2, server 11.12 (Ubuntu 11.12-1.pgdg16.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
example-app::DATABASE=> CREATE EXTENSION postgis;
CREATE EXTENSION
To check if PostGIS is installed on a database, run the following query from psql:
=> SELECT postgis_version();
postgis_version
---------------------------------------
2.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)
Setting Up PostGIS with Rails
To use PostgreSQL as your database in Ruby applications, include the activerecord-postgis-adapter gem in your Gemfile.
To fully take advantage of PostGIS with Rails on Heroku, configure your app with a custom buildpack, which includes the appropriate system dependencies. This classic buildpack for Cedar-generation apps include that support. For now, there is no Cloud Native Buildpack-equivalent for Fir-generation apps.
Be sure to deploy the buildpack before building any gems.
gem 'activerecord-postgis-adapter'
To download and resolve all dependencies, run bundle install. See the Ruby documentation for more information on getting set up with activerecord-postgis-adapter.
After you’ve installed the gem, change the adapter to postgis. See Rails Database Connection Behavior on how to modify your Rails connection adapter.