Building Location Based Apps with Heroku PostGIS

Smartphones have changed the world – everyone has a device in their pocket that’s constantly connected to the internet and knows where you are. Combined with the rise of digital mapping it has become commonplace to build applications that use GIS (Geographical Information Systems) to digitally represent our physical reality and our location in it. Storing and manipulating geospatial data has become an essential part of application development. If you are building a mobile app it’s becoming table stakes that you take advantage of location.

Today we’re releasing PostGIS 2.0 into public beta as an extension to Heroku Postgres. Now all Heroku Postgres customers will be able to store and manipulate geospatial data as part of their Postgres database. PostGIS 2.0 capabilities are now available in all production tier plans at no additional charge—allowing you to add powerful location functionality to your application.

PostGIS 2.0 will enable a new class of Heroku applications that leverage location data. Whether you are looking to compute walkability scores to nearby schools, target ads based on GPS locations, or search for apartments by specific neighborhoods PostGIS can help make you build richer functionality into your application more easily.

PostGIS now follows the standard extension format within Heroku Postgres. Installing PostGIS is as simple as create extension postgis on any new Postgres 9.2 database crane and above. This means that you can continue starting small with your application, grow functionality, then enable PostGIS at any time to begin taking advantage of it.

Get Started

You can get started with PostGIS 2.0 today by provisioning a database then enabling the extension; or read more about what PostGIS provides.

To provision your database:

heroku addons:add heroku-postgresql:crane

Once provisioned you’ll want to connect to it and enable the extension:

$ heroku pg:psql
create extension postgis;

Your geospatial database is now enabled and ready to use.

More about PostGIS

PostGIS is an extension, adding support for geographic objects and working with them, within PostgreSQL. Similar to PostgreSQL itself, PostGIS is open source. Since Heroku Postgres runs unmodified from the main branch you always use standard technology. The technology is flexible and there is no technology lock-in – you can take data in and out at any time.

PostGIS has grown over several years with a large community behind it now supporting a variety of new operators, specialized types, and a long list of functions for interacting with spatial data.

Adding Location to App

While SQL and specifically PostgreSQL can perform basic algebra this method quickly hits limitations when it comes to more complex location searching. Understandably there’s value in providing your users with richer functionality such as searching by neighborhood, by radius of proximity, or by routes versus just direct distance. At PyCon 2013 Julia Grace talked about how some developers use various math tricks to compute distances or you can take an easier approach by using PostGIS.

By using PostGIS whether natively or through Rails with ActiveRecord, Django with GeoDjango, Hibernate you can add a variety of rich functionality around location and geographic data very quickly, including:

To begin taking advantage of the GIS functionality available within your Heroku Postgres database read more in DevCenter on getting it setup with ActiveRecord for Rails or within GeoDjango.


Heroku Postgres is increasingly enabling rich use cases – adding services from key/value datatype in hstore, querying across postgres databases with dblink, and now adding rich geospatial functionality. Adding PostGIS within your Postgres database reduces the number of services you need to add to your stack, reducing complexity and allowing you to build in location-based functionality into apps faster.

Get started integrating location into your apps today by provisioning your Heroku Postgres database and exploring the functionality of PostGIS 2.0.

RailsConf 2013

Developers are worthy of great experiences and at Heroku we aim to help improve this. Whether its making it easier to prepare your application for production on Heroku, not having to worry about security updates in your database, or getting notified of the latest rails vulnerability we want to make the world better for developers. This extends beyond the Heroku platform as well. For instance, our Ruby Task Force contributes back to projects like Ruby on Rails, Bundler, Code Triage, and Rails Girls.

Likewise, we aim to do everything we can to make your RailsConf experience better. Whether it is relaxing with some sake or getting performance advice for your application, we have a slew of activities planned for the conference:

Read more →

Introducing Production Check

Entering production is a key transition in your app’s lifecycle; it signals that your app will be delivering value to end users. You are no longer optimizing for testing—you are optimizing for performance and reliability, and there are new factors to consider at this stage.

Production Check

Today we’re announcing Production Check, an enhancement to the Heroku Dashboard that helps ensure that your app is ready to go to production. Production Check tests your app’s configuration against a set of optional—but highly recommended—criteria. It makes it easy to ensure that your app’s configuration lends itself to maximum uptime. Moreover, it ensures that you have tools available for understanding and monitoring the factors that contribute to uptime.

Read more →

Introducing the Europe Region, Now Available in Public Beta

Today we’re happy to announce Heroku’s Europe region, available in public beta. With more than 3 million apps running on our platform from developers all over the globe, it's not surprising that we've had high demand for Heroku in more regions of the world. After collaborating closely with customers during private beta, we're now ready to offer Heroku services in Europe to all customers as part of a public beta. The Europe region runs Heroku applications from datacenters located in Europe, offering improved performance for users in that region.

Read more →

Expanded HTTP Method Support

HTTP and its secure variant, HTTPS, are the protocols used by every web client to talk to web applications. A key part of the protocol is the HTTP method. Traditionally, web applications used a very limited set of HTTP methods. It is common for application servers, proxies and routers (such as the Heroku HTTP router) to prevent unknown methods from being used. This unnecessary constraint of the Heroku HTTP router has increasingly become a limitation to developers building modern web applications.

In the past, if you tried to use an unsupported HTTP method in your Heroku application, clients would receive a 405 METHOD_NOT_ALLOWED error.

As of today, that's no longer the case. The Heroku routers now accept any HTTP method, allowing you to use newer methods that have recently gained adoption, such as PATCH.

Read more →

Browse the blog archives or subscribe to the full-text feed.