geoalchemy

21
GEOALCHEMY http://erilem.net/talks/foss4g2013/geoalchemy.html

Upload: camptocamp

Post on 01-Nov-2014

970 views

Category:

Technology


0 download

DESCRIPTION

Theme: Development: presentation is focused on a specific technology, demonstrating either a new product or new developments in an existing product. GeoAlchemy is a powerful toolkit to use SQL spatial databases from Python. GeoAlchemy helps you use spatial databases from Python. GeoAlchemy provides extensions to SQLAlchemy, the Python SQL toolkit and ORM. GeoAlchemy builds on SQLAlchemy's extreme flexibility, and can be used for different types of applications, from simple scripts to complex web applications. In this talk we will present GeoAlchemy and SQLAlchemy. We will describe when and how SQLAlchemy and GeoAlchemy can be useful. We will demonstrate the power and flexibility of the tools. We will also present the new version of GeoAlchemy, namely GeoAlchemy 2. GeoAlchemy 2 enables leveraging PostGIS' new features. For example, GeoAlchemy 2 supports PostGIS's new raster type. Finally, we will demonstrate how GeoAlchemy integrates with other well-known Python tools, such as Shapely.

TRANSCRIPT

  • 1. GEOALCHEMYhttp://erilem.net/talks/foss4g2013/geoalchemy.html
  • 2. USE SQL SPATIAL DATABASES FROM PYTHON
  • 3. We have PostGIS. Hooray!
  • 4. We have Python. Horray!
  • 5. We need good ways/tools to use PostGIS from Python.
  • 6. That's the reason we're developing GeoAlchemy
  • 7. Wait! There's Django, and GeoDjango!
  • 8. YES (it's great), BUT...
  • 9. There's a life outside Web and Django!
  • 10. Has anyone heard about Flask, Bottle, Pyramid? They're great frameworks, with lots of users.
  • 11. They all love the SQLAlchemy toolkit. For good reasons!
  • 12. SQLALCHEMY The Database Toolkit for Python
  • 13. SQLALCHEMY PHILOSOPHY It's not about abstracting the DB Abstracting is Hiding It's about Automation Instruct SQLA to do the grunt work we give it Relational form of data is preserved SQLA provides a rich vocabulary to express decisions made by the developer
  • 14. SQLALCHEMY CORE / ORM SQLAlchemy has two distinct areas: Core (SQL expression system) Object Relational Mapper (ORM)
  • 15. SQLALCHEMY QUERY EXAMPLE The user whose email address is [email protected]. user = session.query(User).join(Address). filter(Address.email_address=='[email protected]'). one()
  • 16. GEOALCHEMY Thin layer above SQLAlchemy With the same philosophy
  • 17. GEOALCHEMY QUERY EXAMPLE The lakes whose buffers have areas greater than 33. It looks like SQLA! It looks like PostGIS SQL! lakes = session.query(Lake).filter( Lake.geom.ST_Buffer(2).ST_Area() > 33).all()
  • 18. SHAPELY INTEGRATION to_shapeand from_shapefunctions lake = session.query(Lake).filter( Lake.geom.ST_Buffer(2).ST_Area() > 33).first() lake_shape = to_shape(lake.geom) lake_shape.representative_point().wkt
  • 19. STATUS Version 2 released 6 months ago (03/17/2013) Benefits from SQLALchemy's latest advances Improved API Works both with SQLA Core and ORM PostGIS 2 support (Raster included) Fully documented and tested https://geoalchemy-2.readthedocs.org
  • 20. EXPOSURE Used in production Many client projects by Camptocamp The SkyLines project ( ) By Tobias Bieniek (@Turbo87) https://www.skylines-project.org)
  • 21. THANKS!