All Projects → tilery → Python Postgis

tilery / Python Postgis

PostGIS helpers for psycopg2 and asyncpg

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Python Postgis

tilelive-postgis
Implements the tilelive API for generating vector tiles from PostGIS
Stars: ✭ 48 (-18.64%)
Mutual labels:  postgis
Tegola
Tegola is a Mapbox Vector Tile server written in Go
Stars: ✭ 754 (+1177.97%)
Mutual labels:  postgis
Building Server
A server to stream PostGIS 3D objects to the web
Stars: ✭ 11 (-81.36%)
Mutual labels:  postgis
docker-django
Base Docker image for Django and Gunicorn.
Stars: ✭ 29 (-50.85%)
Mutual labels:  postgis
Spatial
Neo4j Spatial is a library of utilities for Neo4j that faciliates the enabling of spatial operations on data. In particular you can add spatial indexes to already located data, and perform spatial operations on the data like searching for data within specified regions or within a specified distance of a point of interest. In addition classes are provided to expose the data to geotools and thereby to geotools enabled applications like geoserver and uDig.
Stars: ✭ 695 (+1077.97%)
Mutual labels:  postgis
Docker Postgis
Docker image for PostGIS
Stars: ✭ 821 (+1291.53%)
Mutual labels:  postgis
formation-postgis
Formation PostGIS pour les utilisateurs de QGIS
Stars: ✭ 16 (-72.88%)
Mutual labels:  postgis
Osm2pgsql
OpenStreetMap data to PostgreSQL converter
Stars: ✭ 1,042 (+1666.1%)
Mutual labels:  postgis
Activerecord Postgis Adapter
ActiveRecord connection adapter for PostGIS, based on postgresql and rgeo
Stars: ✭ 746 (+1164.41%)
Mutual labels:  postgis
Geography for hackers
Geography for Hackers - Teaching all how to hack geography, use GIS, and think spatially
Stars: ✭ 25 (-57.63%)
Mutual labels:  postgis
Tasking Manager
Tasking Manager - The tool to team up for mapping in OpenStreetMap
Stars: ✭ 328 (+455.93%)
Mutual labels:  postgis
Postgresapp
The easiest way to get started with PostgreSQL on the Mac
Stars: ✭ 6,118 (+10269.49%)
Mutual labels:  postgis
Docker Postgres
A docker container running PostgreSQL
Stars: ✭ 22 (-62.71%)
Mutual labels:  postgis
pgRouting
A SQL script for preparing the OS Open Roads data for use with pgRouting and other stuff
Stars: ✭ 13 (-77.97%)
Mutual labels:  postgis
Postgresql Postgis Timescaledb
PostgreSQL + PostGIS + TimescaleDB docker image 🐘🌎📈
Stars: ✭ 19 (-67.8%)
Mutual labels:  postgis
postile
Project migrated to: https://gitlab.com/Oslandia/postile
Stars: ✭ 67 (+13.56%)
Mutual labels:  postgis
Pgrouting
Repository contains pgRouting library. Development branch is "develop", stable branch is "master"
Stars: ✭ 804 (+1262.71%)
Mutual labels:  postgis
Xyz
An open source javascript framework for spatial data and application interfaces.
Stars: ✭ 54 (-8.47%)
Mutual labels:  postgis
Djangorestframework Mvt
Serve Mapbox Vector Tiles with Django and Postgres
Stars: ✭ 33 (-44.07%)
Mutual labels:  postgis
Postgis
PostGIS spatial database extension to PostgreSQL [mirror]
Stars: ✭ 925 (+1467.8%)
Mutual labels:  postgis

Circle CI PyPI PyPI PyPI PyPI

python-postgis

PostGIS helpers for psycopg2 and asyncpg.

Install

pip install postgis

If you want a compiled version, first install cython:

pip install cython
pip install postgis

Usage

You need to register the extension:

# With psycopg2
> from postgis.psycopg import register
> register(connection)

# With asyncpg
> from postgis.asyncpg import register
> await register(connection)

Then you can pass python geometries instance to psycopg:

> cursor.execute('INSERT INTO table (geom) VALUES (%s)', [Point(x=1, y=2, srid=4326)])

And retrieve data as python geometries instances:

> cursor.execute('SELECT geom FROM points LIMIT 1')
> geom = cursor.fetchone()[0]
> geom
<Point POINT(1.0 2.0)>

Example with psycopg2

> import psycopg2
> from postgis import LineString
> from postgis.psycopg import register
> db = psycopg2.connect(dbname="test")
> register(db)
> cursor.execute('CREATE TABLE IF NOT EXISTS mytable ("geom" geometry(LineString) NOT NULL)')
> cursor.execute('INSERT INTO mytable (geom) VALUES (%s)', [LineString([(1, 2), (3, 4)], srid=4326)])
> cursor.execute('SELECT geom FROM mytable LIMIT 1')
> geom = cursor.fetchone()[0]
> geom
<LineString LINESTRING(1.0 2.0, 3.0 4.0)>
> geom[0]
<Point POINT(1.0 2.0)>
> geom.coords
((1.0, 2.0), (3.0, 4.0))
> geom.geojson
{'coordinates': ((1.0, 2.0), (3.0, 4.0)), 'type': 'LineString'}
> str(geom.geojson)
'{"type": "LineString", "coordinates": [[1, 2], [3, 4]]}'

Example with asyncpg

from postgis.asyncpg import register
pool = await create_pool(**DB_CONFIG, loop=loop, max_size=100,
                         init=register)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].