:orphan:

.. _gallery:

Gallery
=======



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Sometimes the application wants to apply a function in an insert or in a select. For example, the application might need the geometry with lat/lon coordinates while they are projected in the DB. To avoid having to always tweak the query with a ST_Transform(), it is possible to define a TypeDecorator">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_type_decorator_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_type_decorator.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Automatically use a function at insert or select</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="It is possible to insert a geometry and ask PostgreSQL to compute its length at the same time. This example uses SQLAlchemy core queries.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_length_at_insert_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_length_at_insert.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Compute length on insert</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The RasterElement objects store the Raster data in WKB form. When using rasters it is usually better to convert them into TIFF, PNG, JPEG or whatever. Nevertheless, it is possible to decipher the WKB to get a 2D list of values. This example uses SQLAlchemy ORM queries.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_decipher_raster_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_decipher_raster.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Decipher Raster</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="If the application wants to build queries with GeoAlchemy 2 and gets them as strings, the wrapping of geometry columns with a ST_AsEWKB() function might be annoying. In this case it is possible to disable this wrapping. This example uses SQLAlchemy ORM queries.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_disable_wrapping_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_disable_wrapping.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Disable wrapping in select</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Some functions have different names depending on the dialect. But sometimes one function in one dialect can be mapped to several other functions in another dialect, depending on the arguments passed. For example, the ST_Buffer function in PostgreSQL can translate into 2 functions in SQLite:">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_specific_compilation_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_specific_compilation.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Function translation for specific dialect</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The RasterElement objects store the Raster data in WKB form. This WKB format is usually fetched from the database but when the data comes from another source it can be hard to format it as as a WKB. This example shows a method to convert input data into a WKB in order to insert it. This example uses SQLAlchemy ORM queries.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_insert_raster_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_insert_raster.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Insert Raster</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="SQLAlchemy&gt;=2 introduced a new way to construct mappings using the sqlalchemy.orm.DeclarativeBase base class. This example shows how to use GeoAlchemy2 types in this context.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_orm_mapped_v2_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_orm_mapped_v2.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">New ORM Declarative Mapping Style</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The ST_Transform() function (and a few others like ST_SnapToGrid()) can be used on both Geometry and Raster types. In GeoAlchemy2, this function is only defined for Geometry as it can not be defined for several types at the same time. Thus using this function on Raster requires minor tweaking.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_raster_transform_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_raster_transform.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Reproject a Raster using ST_Transform</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Some functions return composite types. This example shows how to deal with this kind of functions.">

.. only:: html

  .. image:: /gallery/images/thumb/sphx_glr_test_summarystatsagg_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_test_summarystatsagg.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Use CompositeType</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /gallery/test_type_decorator
   /gallery/test_length_at_insert
   /gallery/test_decipher_raster
   /gallery/test_disable_wrapping
   /gallery/test_specific_compilation
   /gallery/test_insert_raster
   /gallery/test_orm_mapped_v2
   /gallery/test_raster_transform
   /gallery/test_summarystatsagg



.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
