Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Test for postgis

Project Description


Add types and functions to work with geometric attributes that are stored in a Postgis database (that is a PostgreSQL database with Postgis extension enabled).

The present cube supports only version 2.0 and later of Postgis.

It introduces one new type when defining attributes in the data model schema:

  • a Geometry type. Additionally, you should give the following elements along with a Geometry attribute:
    • geom_type. The Postgis type of geometries that this attribute will accept, for example POINT, MULTILINESTRING or POLYGON,
    • srid. The spatial reference system the geometry coordinates will live in. This is an integer and a foreign key that must match the srid key in the spatial_ref_sys table. Most of the time, it will be the same as the spatial system EPSG code,
    • coord_dimension. The number of dimensions used by geometries. Defaults to 2.
  • a Geography type (see the description).

Then you can also use geometric functions like ST_INTERSECTS, ST_WITHIN or ST_UNION to work with this new type.

See Postgis manual for reference documentation about Postgis.


In, one can declare a City entity like the following.

class City(EntityType):
    name = String(required=True)
    geometry = Geometry(geom_type='POLYGON', srid=4326)

You may then make queries like:

# get all cities in a given bounding box
    '%(left)s, %(bottom)s, %(right)s, %(top)s, 4326)) = TRUE)',
        {'left': 2.2,
        'right': 2.6,
        'top': 49,
        'bottom': 48})

# get all cities at a given distance from a point, sorted by distance
rql('Any C, ST_DISTANCE(G, ST_SETSRID(ST_MAKEPOINT(2.2, 48.4), 4326)) '
        'C geometry G HAVING ('
        ' ST_DWITHIN(G, ST_SETSRID(ST_MAKEPOINT(2.2, 48.4), 4326), 0.1) = TRUE)')

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(7.5 kB) Copy SHA256 Hash SHA256
Source Sep 28, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting