SlideShare a Scribd company logo
The Canadian
            Spatial Data Foundry

                                    Introduction to
                           PostGIS WKT Raster and
                                  “Raster Objects”


Pierre Racine                     Boreal Avian
                                  Modelling Project
Professionnel de recherche
Département des sciences du bois et de la forêt
1 - The Canadian Spatial Data Foundry
                     The Context
• Many researchers in forestry, ecology and environment
• Interested in habitat selection modelling
  - Where do organisms prefer to live?


                                   shape    obsID   cutProp meanTemp elevation   etc…
                                  polygon     1      75.2     20.3     450.2      …
                                  polygon     2      26.3     15.5     467.3      …
                                  polygon     3      56.8     17.5     564.8      …
                                  polygon     4      69.2     10.4     390.2      …
                                      …               …        …         …        …




                               etc…
1 - The Canadian Spatial Data Foundry
                        The Problem
Researchers must…
…learn lots of ArcGIS, to use only a few operations
…search for, download and assemble large datasets
  - historical data are often lost
  - data are delivered in many different formats
  - datasets are too large to fit in one file (shp limited to 2 GB, complete
   forest cover for Canada is 30GB, complete DEM for Canada is 9 GB, etc…)
  - computation is often too difficult for ArcGIS (800 buffers over 5 000 000
   polygons)

…struggle for weeks, if not months, to get their data table
 ready for statistical analysis…

   In brief: researchers waste much energy on tasks
       unrelated to their main priority: research!!!
The Canadian Spatial Data Foundry
             The Envisioned Solution
• Building a paying web service
• Backed by a spatial database (PostGIS) hosted on a supercomputer
• Administrators upload preassembled datasets of ecological layers
  (vector & raster, historical data included)
• Users with accounts upload their datasets (shapefiles)
• Create intersection queries on the ecological layers
• Obtain resulting shapefiles or tables (minutes, hours
  or days later)

   Users         Web server         Supercomputer       Administrators
shapefiles         Web                PostgreSQL
                  service                                 geospatial
                                       PostGIS
                                                            data
  queries                             users’ layers
                              SQL
                                      intersections
  table or                          ecological layers
 shapefile
The Canadian Spatial Data Foundry
            What is a spatial database?
• DBMS with native support for the geometry type
  -   Normalisation                           shapefile         spatial DB
  -   Standard Query Language (SQL)            properties         properties          districts
                                              shape    owner   geometry owner      geometry   id
  -   Transactions & Rules
                                             polygon   Jean     polygon   Jean     polygon AB12
  -   Security & Backup                      polygon Pierre     polygon   Pierre   polygon CF34
                                             polygon   Marc     polygon   Marc     polygon RT43
  -   Functions & Operators                  polygon   Jean     polygon   Jean     polygon RE42
      (intersect(), within(), area(),          …        …         …        …          …       …

      =, &&, etc…)
  SELECT area(geometry), owner FROM properties, districts
  WHERE intersect(properties.geometry, districts.geometry) and district.id = “AB12”
  - What is the area — and who is the owner — of properties located in district AB12?


• IBM DB2 Spatial Extender, Informix Spatial DataBlade, Oracle Spatial,
  PostgreSQL/PostGIS, ESRI's ArcSDE, Intergraph's GeoMedia
• What about raster?
Raster Support Requirements
     1 - Storage of Non Rectangular Raster Coverage

• We have to be able to store not only “ideal”
  rectangular raster datasets…
                                                “Real” Raster Dataset
 “Ideal” Raster Dataset
                             landcover
                          tileId      raster
                             1     rasterBLOB
                             2     rasterBLOB
                             3     rasterBLOB
                             4     rasterBLOB
                             5     rasterBLOB
                            …           …
                            53     rasterBLOB
                            54     rasterBLOB


                                                 e.g. SRTM Coverage for Canada

• …but also “real” non-rectangular
  raster coverages
Raster Support Requirements
2 - Easy Importation/Exportation




                 PostgreSQL
       import                        export
                  PostGIS

                 ecological layers




The way to import raster layers should not differ
 much from the way to import vector layers…
Raster Support Requirements
   3 - SQL Functions & Operators on the Raster Type

• Raster Attributes
  - area(), srid(), width(), height(), pixeltype(), pixelsize(),
    nodatavalue(), georeference(), etc…

• Raster Transformation
  - reproject(), translate(), scale(), resample(), clip(), reclass(),
    mapalgebra(), etc…

• Raster Aggregation
  - Merge of many rasters using GROUP BY (accum())

• Raster Conversion
  - toJPEG(), toTIFF(), to KML(), toPolygon()…
Raster Support Requirements
         4 - Lossless Conversion Between Vector and Raster Layers

• Categorical rasters layers convert




                                                                                  vectorisation
  well to vector layers
 -   one variable converts to one column
 -   groups together pixels of same value
 -   contiguous or not                                           landcover                           landcover
                                                                                                  geometry   type
 -   continuous raster layers do not convert as well                                              polygon      4
                                                                                                  polygon      3
                                                                                                  polygon      7
• Vector layers do not convert well to raster layers                                                 …        …

 - each attribute (e.g. type) must be




                                                                                  rasterisation
   converted to one raster
 - no support for nominal values (e.g. “M34”)
 - global values (area) lose their meaning
 - overlaps are lost                                       landcover                                landcover
 - resolution must be high to match vector        geometry type mapsheet area                      mapsheet
                                                   polygon   4    M34    13.34
   precision                                       polygon   3    M33    15.43                       area
                                                   polygon   7    M33    10.56
 - features lose their unique identities              …     …      …      …
 - reconversion to the original vector is very difficult or impossible
     We need a better way to convert vector layers to rasters without destroying the objects’ identities
Raster Support Requirements
         4 - Lossless Conversion Between Vector and Raster Layers

• In a vector layer, each object has its own identity
                                       landcover
                             geometry type mapsheet area
                             polygon    4    M34    13.34
                             polygon    3    M33    15.43
                             polygon    7    M33    10.56
                             polygon    9    M34    24.54
                             polygon    5    M33    23.43
                             polygon    2    M32    12.34
                                …      …      …      …



• In a raster layer converted from a vector layer, each object should conserve its
  own identity
                                       landcover
                              raster   type   mapsheet   area
                              raster     4      M34      13.34
                              raster     3      M33      15.43
                              raster     7      M33      10.56
                              raster     9      M34      24.54
                              raster     5      M33      23.43
                              raster     2      M32      12.34
                                …       …        …        …

   -   Each “raster object” has its own georeference       Rasters become just another way to store
   -   Black pixels are “nodata values”                    geographic features in a more expressive
   -   Like vectors, raster objects may or may not overlap       vector object-oriented-like style
   -   Raster algorithms can be used on the whole layer after a “blend” of the objects into a single raster
Raster Support Requirements
                 5 - Seamless Spatial Operators & Functions
                         on Vector and Raster Types

• The goal is to be able to use a single set of SQL functions & operators
  without worrying if data are stored in vector format or raster format.
   - Same deployment strategy (SQL)
   - No longer need to implement overlay operations in two different ways

                            observation         cover                   result
                             geom obsid        raster ctype
                                               geom                geom obsid ctype area
                             point
                            polygon
                             point
                            polygon
                             point
                            polygon
                                    24
                                    31
                                    45
                                          ∩   polygon
                                               raster
                                              polygon
                                               raster
                                              polygon
                                               raster
                                                        4
                                                        3
                                                        5
                                                              =   polygon
                                                                  polygon
                                                                  polygon
                                                                          24
                                                                          53
                                                                          24
                                                                                4
                                                                                3
                                                                                5
                                                                                    10.34
                                                                                    11.23
                                                                                    14.23
                               …    …         polygon
                                               raster   2         polygon 23    2    9.45
                                                 …     …             …    …     …     …




   SELECT geom, obsid, ctype, Area(geom) as area FROM (
   SELECT Intersection(Buffer(observation.geom, 1000), cover.geom) as geom, obsid, type
   FROM observation, cover
   WHERE Intersects(Buffer(point.geom, 1000), cover.geom)
   ) result
   - area(), intersections(), buffer(), within(), overlaps(), reclass(), transform(),
     centroid(), and many more…
Raster Support Requirements
  6 - Storage of Raster Outside of the Database

• Goals:
  - Provide faster access to raster files (JPEGs) for web applications
  - Avoid useless database backup of large non-edited datasets
  - Avoid importation (copy) of large datasets into the database

                               Web server
                               Web service

                          SQL
                                               JPEGs

                   landcover
                                             Image01.jpg
                     raster                   Image02.jpg
                     raster
                     raster                    Image03.jpg
                     raster
                     raster
                                                Image04.jpg
                       …                               …
Raster Support Requirements
       What about Oracle GeoRaster?
• Stored as a relation between two types in different tables:
   - images (SDO_GEORASTER for type, extent, rasterTable, id, metadata)
   - blocks (tiles) (SDO_RASTER for block information)
                                                   images                                rasterTable3 (blocks)
                                                                                 id           rasterTable3 (blocks)
                                                                                                    SDO_RASTER
                                   id           SDO_GEORASTER
                                                                                     id,        rasterTable3 (blocks)
                                                                                  1id pyrLevel, band, row, col, MBR, BLOB
                                                                                                     SDO_RASTER
                                    1 type, extent, rasterTable1, id, metadata
                                    2 type, extent, rasterTable2, id, metadata    2 1id, pyrLevel, band, row, col, MBR, BLOB
                                                                                     id pyrLevel, band, row, col, MBR, BLOB
                                                                                       id,             SDO_RASTER
• Supports:                         3 type, extent, rasterTable3, id, metadata    3 2id, id, pyrLevel, band, row, col, MBR, BLOB
                                                                                      1id, pyrLevel, band, row, col, MBR, BLOB
                                                                                          pyrLevel, band, row, col, MBR, BLOB
                                                                                    3 2id, pyrLevel, band, row, col, MBR, BLOB
                                                                                         id, pyrLevel, band, row, col, MBR, BLOB
                                                          …                                               …
   -   bitmap mask                                                                    3 id, pyrLevel, band, row, col, MBR, BLOB
                                                                                                           …
                                                                                                             …
   -   two compression schemes
   -   three interleaving types
   -   multiple dimensions
   -   embedded metadata (colour table, statistics, etc…)
   -   lots of unimplemented features



• PostGIS PgRaster adopts a very similar approach
Raster Support Requirements
      Does the Oracle GeoRaster’s architecture fulfill our requirements?


        Requirement              Yes/No                 Comments
1) Non-rectangular raster                  Creates as many tables as there are
                                 Yes but   rasters. 1000 rasters = 1000 tables
   coverage
2) Easy import/export                      Request manual table creation or
                                   No
                                           FME ($$$)
3) SQL functions & operators      Yes      Although limited
   on the raster type
4) Lossless vector/raster
                                   No
   conversion
5) Seamless vector/raster                  Really not designed for this…
                                   No
   spatial functions/operators
6) Out-DB Storage                  No



                            Not really…
PostGIS WKT Raster
 An Open Source project specifically designed to meet these requirements

        Requirement              Yes/No                      Comments
1) Non-rectangular raster                 Into a single table.
                                  Yes
   coverage
                                  Yes     Very similar to PostGIS shp2pgsql.exe &
2) Easy import/export                     pgsql2shp.exe (gdal2wktraster.py)

                                          ST_Width(), ST_Height(), ST_BandPixelType(),
3) SQL functions & operators              ST_PixelSizeX(), ST_PixelSizeY(), ST_NumBands(),
   on the raster type             Yes     ST_BandNoDataValue(), ST_GDALGeoTransform(),
                                          ST_Resample(), ST_Clip(), ST_Reclass(),
                                          ST_MapAlgebra(), ST_AsJPEG(), ST_AsTIFF(),
                                          ST_AsPolygon(), etc…


4) Lossless vector/raster                 Every raster (or tile) of a single coverage has its
                                  Yes     own georeference and hence can overlap other
   conversion                             rasters.
                                          ST_Area(), ST_SRID(), ST_Transform(), ST_Union(),
5) Seamless vector/raster                 AT_Accum(), ST_AsKML(), ST_AsSVG(), ST_Translate(),
   spatial functions/operators    Yes     ST_Scale(), ST_Intersection(), ST_Intersects(),
                                          ST_Within(), ST_PointOnSurface(), &&, etc…

6) Out-DB Storage                 Yes     Only filepaths are stored in the database.
PostGIS WKT Raster Status
• Contributions
 - Initial code base developed by Sandro Santilli, funded by Steve Cumming (UL, Canada)
   and Tyler Erickson (Michigan Tech Research Institute)
 - Basic functions, python importer, overviews and regular tiling code: Mateusz Loskot
   (CadCorp, UK)
 - GDAL Driver foundation: Jorge Arevalo (Google Summer of Code spanish student)
• Version Beta 0.1 to be released this winter. Will include:
 - gdal2wktraster.py importer
 - Overviews (multiresolution pyramids) support
 - Accessor Functions (ST_SRID(), ST_Width(), ST_Height(), ST_PixelSizeX(), ST_PixelSizeY(),
   ST_RotationX(), ST_RotationY(), ST_UpperLeftX(), ST_UpperLeftY(), ST_ESRIWorldFile(),
   ST_GDALGeoTransform(), ST_NumBands(), ST_BandPixelType(), ST_BandNoDataValue())
 - Basic Seamless Overlay Functions (ST_Intersects(), ST_Intersections(), ST_AsPolygon(),
   ST_Envelope(), ST_Shape())
 - Spatial operators identical to the one on the geometry type (&&, &<, etc…)
 - Out-DB raster registration with gdal2wktraster.py
 - Well documented web site (doc & wiki specs, http://trac.osgeo.org/postgis/wiki/WKTRaster)
• We also need your help! You can provide developer time or funds…
Introducing
     WKT Raster « Raster Objects »
• The fact that every raster in a PostGIS WKT Raster table
  has its own georeference and attributes, and is thus
  independent of other rasters in the table, is a very
  interesting characteric of those raster objects.
• Like vector geometries, raster objects:
  - can overlap
  - can change location
  - can represent individual objects with their own identity

• Moreover, raster objects can be used to model real life
  objects better represented as small fields (like fires or
  fuzzy objects).
• Very new type of GIS object
Introducing WKT Raster Objects
        Raster Objects vs Other GIS Objects
• Point and Line Coverages
• Polygon Coverages
 - Objects represent a constant surface with an identity and
   properties (like an object in a OO context)

• Raster Object Coverages
 - Constant Raster Objects (categorical)
    Objects represent a constant surface with an identity and properties (like a
    feature or an object)
    Better modelled as polygon, but modelled as raster because they are better
    processed using existing raster algorithms (eg. landcover, basin)
    E.g.: land use; land cover; traditional raster objects that should overlap but can’t
    because they are in raster format (ex. buffers, animal territories)

 - Variable Raster Objects (field)
    Objects represent a variable field that have an identity and properties
    Generally modelised as a unique raster and difficult to
    model as polygons
    E.g.: fire, fuzzy objects (lakes, land cover, forest
    stands, soil), area of influence, animal territories

• Traditional Raster Coverages
 - Represent a variable field with
   different values (no unique identity or other properties)
 - E.g.: elevation, climate, etc…
Summary
• The Canadian Spatial Data Foundry should facilitate, via a web
  service, GIS intersection operations over large-scale ecological
  datasets (vector & raster)
• Oracle GeoRaster does not provide a good integration between raster
  and vector layer
• PostGIS WKT Raster aims to provide such an integration
  -   Support non-rectangular raster coverages
  -   Lossless conversion between raster & vector layers
  -   Seamless operators & functions on raster & vector types
  -   Storage of raster outside the DB
  -   Easy import/export similar to shp2pgsql.exe
  -   We need your help!
• WKT Raster introduces a new kind of GIS raster objects that
  are useful for modelling:
  - categorical features needing raster algorithms
  - fuzzy objects requiring their own identities
Thanks!

• http://trac.osgeo.org/postgis/wiki/WKTRaster




                 Boreal Avian
                 Modelling Project

More Related Content

PDF
Csr2011 june16 11_30_georgiadis
PPT
Accès et Utilisation de RADARSAT-2
PDF
Act 00035 geo met 2 accès ouvert aux données météorologiques d'environnement...
PDF
Act 00028 parce qu'une ville moyenne peut aussi être intelligente…
PDF
Act 00091 connaître sa zone commerciale la clé d’un réseau optimal
PDF
Act 00025 expérimentations d’un géoradar (gpr) pour des levés d’arpentage et ...
PDF
Act 00085 i towns, nouveau framework pour la visualisation 3d web
PDF
Act 00068 la stratégie d’élévation nationale
Csr2011 june16 11_30_georgiadis
Accès et Utilisation de RADARSAT-2
Act 00035 geo met 2 accès ouvert aux données météorologiques d'environnement...
Act 00028 parce qu'une ville moyenne peut aussi être intelligente…
Act 00091 connaître sa zone commerciale la clé d’un réseau optimal
Act 00025 expérimentations d’un géoradar (gpr) pour des levés d’arpentage et ...
Act 00085 i towns, nouveau framework pour la visualisation 3d web
Act 00068 la stratégie d’élévation nationale

Similar to Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster (20)

PPTX
Terrain in Battlefield 3: A Modern, Complete and Scalable System
PPTX
RTree Spatial Indexing with MongoDB - MongoDC
PDF
Arc gis introduction-ppt
PDF
GIS data structure
PPTX
Cbir ‐ features
PPTX
Collaborative Similarity Measure for Intra-Graph Clustering
PDF
14 spatial analyst
PDF
Data managing and Exchange GDB
PPTX
Geographic Information System for Egyptian Railway System(GIS)
PDF
The state of geo in ElasticSearch
PPTX
WOOster: A Map-Reduce based Platform for Graph Mining
PDF
Gis and digital_map_fundamentals
PPT
Geoservices Activities at EDINA
PDF
Using postgre sql for 3d cms
PDF
Skills portfolio
PDF
Using Imagery in ArcGIS
PDF
Shadow Warrior 2 and the evolution of the Roadhog Engine, GIC15
PPTX
High Dimensional Indexing using MongoDB (MongoSV 2012)
PPTX
Strabon: A Semantic Geospatial Database System
PDF
IBM Spark Technology Center: Real-time Advanced Analytics and Machine Learnin...
Terrain in Battlefield 3: A Modern, Complete and Scalable System
RTree Spatial Indexing with MongoDB - MongoDC
Arc gis introduction-ppt
GIS data structure
Cbir ‐ features
Collaborative Similarity Measure for Intra-Graph Clustering
14 spatial analyst
Data managing and Exchange GDB
Geographic Information System for Egyptian Railway System(GIS)
The state of geo in ElasticSearch
WOOster: A Map-Reduce based Platform for Graph Mining
Gis and digital_map_fundamentals
Geoservices Activities at EDINA
Using postgre sql for 3d cms
Skills portfolio
Using Imagery in ArcGIS
Shadow Warrior 2 and the evolution of the Roadhog Engine, GIC15
High Dimensional Indexing using MongoDB (MongoSV 2012)
Strabon: A Semantic Geospatial Database System
IBM Spark Technology Center: Real-time Advanced Analytics and Machine Learnin...
Ad

More from ACSG Section Montréal (20)

PDF
Centralisation, transformation et distribution de l’imagerie aérienne des vil...
PDF
Inventaire informatisé et intelligent d’arbres
PDF
Une librairie de développement cartographique en libre service
PDF
German Gonzalez - Consortech - Exemples d’utilisation d’API avec FME - Meetup...
PDF
Geoffroy Richer-Lalonde - Hydro-Québec - Plateforme de coordination des Proje...
PPTX
Martin Chevrier - Survol de 20 ans de géomatique - Meetup - GeoMTL - 2021-03-11
PPTX
Dronautique Laval
PDF
Cartographie d'un jeu de type voxel
PDF
Samuel Mehenni - Covid, mobilité et narratif géospatial - Meetup - GéoMTL - 2...
PDF
Julien Belvisi - État des lieux sur la géomatique en temps de pandémie - Meet...
PDF
Fabmob Meetup GeoMTL
PDF
Centre expertise géomatique Montréal
PPT
Ville de Montréal - Dendrometrie arbres 3d ville montreal_geomtl
PDF
Gabriel Damant-Sirois (Local Logic) | Données géospatiales et technologies:...
PDF
Vincent Sarago (Mapbox) | Traitement d’imagerie satellitaires de masse en ut...
PDF
Tim Elrick (McGill- GIC) | Creating Open Data – the Building Canada 2020 Ini...
PDF
Act 00063 les objets connectés en complément à la géolocalisation
PPSX
Act 00018 architecture ouverte pour une gestion optimale de l’information géo...
PDF
Présentation du Keynote du jeudi 20 octobre 2016 - M. Paul Ramsey
PDF
Act 00109 géo-trafic la plateforme mobilité temps-réel de la ville de montréal
Centralisation, transformation et distribution de l’imagerie aérienne des vil...
Inventaire informatisé et intelligent d’arbres
Une librairie de développement cartographique en libre service
German Gonzalez - Consortech - Exemples d’utilisation d’API avec FME - Meetup...
Geoffroy Richer-Lalonde - Hydro-Québec - Plateforme de coordination des Proje...
Martin Chevrier - Survol de 20 ans de géomatique - Meetup - GeoMTL - 2021-03-11
Dronautique Laval
Cartographie d'un jeu de type voxel
Samuel Mehenni - Covid, mobilité et narratif géospatial - Meetup - GéoMTL - 2...
Julien Belvisi - État des lieux sur la géomatique en temps de pandémie - Meet...
Fabmob Meetup GeoMTL
Centre expertise géomatique Montréal
Ville de Montréal - Dendrometrie arbres 3d ville montreal_geomtl
Gabriel Damant-Sirois (Local Logic) | Données géospatiales et technologies:...
Vincent Sarago (Mapbox) | Traitement d’imagerie satellitaires de masse en ut...
Tim Elrick (McGill- GIC) | Creating Open Data – the Building Canada 2020 Ini...
Act 00063 les objets connectés en complément à la géolocalisation
Act 00018 architecture ouverte pour une gestion optimale de l’information géo...
Présentation du Keynote du jeudi 20 octobre 2016 - M. Paul Ramsey
Act 00109 géo-trafic la plateforme mobilité temps-réel de la ville de montréal
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Tartificialntelligence_presentation.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
MYSQL Presentation for SQL database connectivity
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Tartificialntelligence_presentation.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Per capita expenditure prediction using model stacking based on satellite ima...
Group 1 Presentation -Planning and Decision Making .pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
NewMind AI Weekly Chronicles - August'25-Week II
MIND Revenue Release Quarter 2 2025 Press Release
Building Integrated photovoltaic BIPV_UPV.pdf
Encapsulation theory and applications.pdf
Machine learning based COVID-19 study performance prediction
MYSQL Presentation for SQL database connectivity
A comparative analysis of optical character recognition models for extracting...
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
20250228 LYD VKU AI Blended-Learning.pptx
Assigned Numbers - 2025 - Bluetooth® Document

Le projet “Canadian Spatial Data Foundry”: Introduction à PostGIS WKT Raster

  • 1. The Canadian Spatial Data Foundry Introduction to PostGIS WKT Raster and “Raster Objects” Pierre Racine Boreal Avian Modelling Project Professionnel de recherche Département des sciences du bois et de la forêt
  • 2. 1 - The Canadian Spatial Data Foundry The Context • Many researchers in forestry, ecology and environment • Interested in habitat selection modelling - Where do organisms prefer to live? shape obsID cutProp meanTemp elevation etc… polygon 1 75.2 20.3 450.2 … polygon 2 26.3 15.5 467.3 … polygon 3 56.8 17.5 564.8 … polygon 4 69.2 10.4 390.2 … … … … … … etc…
  • 3. 1 - The Canadian Spatial Data Foundry The Problem Researchers must… …learn lots of ArcGIS, to use only a few operations …search for, download and assemble large datasets - historical data are often lost - data are delivered in many different formats - datasets are too large to fit in one file (shp limited to 2 GB, complete forest cover for Canada is 30GB, complete DEM for Canada is 9 GB, etc…) - computation is often too difficult for ArcGIS (800 buffers over 5 000 000 polygons) …struggle for weeks, if not months, to get their data table ready for statistical analysis… In brief: researchers waste much energy on tasks unrelated to their main priority: research!!!
  • 4. The Canadian Spatial Data Foundry The Envisioned Solution • Building a paying web service • Backed by a spatial database (PostGIS) hosted on a supercomputer • Administrators upload preassembled datasets of ecological layers (vector & raster, historical data included) • Users with accounts upload their datasets (shapefiles) • Create intersection queries on the ecological layers • Obtain resulting shapefiles or tables (minutes, hours or days later) Users Web server Supercomputer Administrators shapefiles Web PostgreSQL service geospatial PostGIS data queries users’ layers SQL intersections table or ecological layers shapefile
  • 5. The Canadian Spatial Data Foundry What is a spatial database? • DBMS with native support for the geometry type - Normalisation shapefile spatial DB - Standard Query Language (SQL) properties properties districts shape owner geometry owner geometry id - Transactions & Rules polygon Jean polygon Jean polygon AB12 - Security & Backup polygon Pierre polygon Pierre polygon CF34 polygon Marc polygon Marc polygon RT43 - Functions & Operators polygon Jean polygon Jean polygon RE42 (intersect(), within(), area(), … … … … … … =, &&, etc…) SELECT area(geometry), owner FROM properties, districts WHERE intersect(properties.geometry, districts.geometry) and district.id = “AB12” - What is the area — and who is the owner — of properties located in district AB12? • IBM DB2 Spatial Extender, Informix Spatial DataBlade, Oracle Spatial, PostgreSQL/PostGIS, ESRI's ArcSDE, Intergraph's GeoMedia • What about raster?
  • 6. Raster Support Requirements 1 - Storage of Non Rectangular Raster Coverage • We have to be able to store not only “ideal” rectangular raster datasets… “Real” Raster Dataset “Ideal” Raster Dataset landcover tileId raster 1 rasterBLOB 2 rasterBLOB 3 rasterBLOB 4 rasterBLOB 5 rasterBLOB … … 53 rasterBLOB 54 rasterBLOB e.g. SRTM Coverage for Canada • …but also “real” non-rectangular raster coverages
  • 7. Raster Support Requirements 2 - Easy Importation/Exportation PostgreSQL import export PostGIS ecological layers The way to import raster layers should not differ much from the way to import vector layers…
  • 8. Raster Support Requirements 3 - SQL Functions & Operators on the Raster Type • Raster Attributes - area(), srid(), width(), height(), pixeltype(), pixelsize(), nodatavalue(), georeference(), etc… • Raster Transformation - reproject(), translate(), scale(), resample(), clip(), reclass(), mapalgebra(), etc… • Raster Aggregation - Merge of many rasters using GROUP BY (accum()) • Raster Conversion - toJPEG(), toTIFF(), to KML(), toPolygon()…
  • 9. Raster Support Requirements 4 - Lossless Conversion Between Vector and Raster Layers • Categorical rasters layers convert vectorisation well to vector layers - one variable converts to one column - groups together pixels of same value - contiguous or not landcover landcover geometry type - continuous raster layers do not convert as well polygon 4 polygon 3 polygon 7 • Vector layers do not convert well to raster layers … … - each attribute (e.g. type) must be rasterisation converted to one raster - no support for nominal values (e.g. “M34”) - global values (area) lose their meaning - overlaps are lost landcover landcover - resolution must be high to match vector geometry type mapsheet area mapsheet polygon 4 M34 13.34 precision polygon 3 M33 15.43 area polygon 7 M33 10.56 - features lose their unique identities … … … … - reconversion to the original vector is very difficult or impossible We need a better way to convert vector layers to rasters without destroying the objects’ identities
  • 10. Raster Support Requirements 4 - Lossless Conversion Between Vector and Raster Layers • In a vector layer, each object has its own identity landcover geometry type mapsheet area polygon 4 M34 13.34 polygon 3 M33 15.43 polygon 7 M33 10.56 polygon 9 M34 24.54 polygon 5 M33 23.43 polygon 2 M32 12.34 … … … … • In a raster layer converted from a vector layer, each object should conserve its own identity landcover raster type mapsheet area raster 4 M34 13.34 raster 3 M33 15.43 raster 7 M33 10.56 raster 9 M34 24.54 raster 5 M33 23.43 raster 2 M32 12.34 … … … … - Each “raster object” has its own georeference Rasters become just another way to store - Black pixels are “nodata values” geographic features in a more expressive - Like vectors, raster objects may or may not overlap vector object-oriented-like style - Raster algorithms can be used on the whole layer after a “blend” of the objects into a single raster
  • 11. Raster Support Requirements 5 - Seamless Spatial Operators & Functions on Vector and Raster Types • The goal is to be able to use a single set of SQL functions & operators without worrying if data are stored in vector format or raster format. - Same deployment strategy (SQL) - No longer need to implement overlay operations in two different ways observation cover result geom obsid raster ctype geom geom obsid ctype area point polygon point polygon point polygon 24 31 45 ∩ polygon raster polygon raster polygon raster 4 3 5 = polygon polygon polygon 24 53 24 4 3 5 10.34 11.23 14.23 … … polygon raster 2 polygon 23 2 9.45 … … … … … … SELECT geom, obsid, ctype, Area(geom) as area FROM ( SELECT Intersection(Buffer(observation.geom, 1000), cover.geom) as geom, obsid, type FROM observation, cover WHERE Intersects(Buffer(point.geom, 1000), cover.geom) ) result - area(), intersections(), buffer(), within(), overlaps(), reclass(), transform(), centroid(), and many more…
  • 12. Raster Support Requirements 6 - Storage of Raster Outside of the Database • Goals: - Provide faster access to raster files (JPEGs) for web applications - Avoid useless database backup of large non-edited datasets - Avoid importation (copy) of large datasets into the database Web server Web service SQL JPEGs landcover Image01.jpg raster Image02.jpg raster raster Image03.jpg raster raster Image04.jpg … …
  • 13. Raster Support Requirements What about Oracle GeoRaster? • Stored as a relation between two types in different tables: - images (SDO_GEORASTER for type, extent, rasterTable, id, metadata) - blocks (tiles) (SDO_RASTER for block information) images rasterTable3 (blocks) id rasterTable3 (blocks) SDO_RASTER id SDO_GEORASTER id, rasterTable3 (blocks) 1id pyrLevel, band, row, col, MBR, BLOB SDO_RASTER 1 type, extent, rasterTable1, id, metadata 2 type, extent, rasterTable2, id, metadata 2 1id, pyrLevel, band, row, col, MBR, BLOB id pyrLevel, band, row, col, MBR, BLOB id, SDO_RASTER • Supports: 3 type, extent, rasterTable3, id, metadata 3 2id, id, pyrLevel, band, row, col, MBR, BLOB 1id, pyrLevel, band, row, col, MBR, BLOB pyrLevel, band, row, col, MBR, BLOB 3 2id, pyrLevel, band, row, col, MBR, BLOB id, pyrLevel, band, row, col, MBR, BLOB … … - bitmap mask 3 id, pyrLevel, band, row, col, MBR, BLOB … … - two compression schemes - three interleaving types - multiple dimensions - embedded metadata (colour table, statistics, etc…) - lots of unimplemented features • PostGIS PgRaster adopts a very similar approach
  • 14. Raster Support Requirements Does the Oracle GeoRaster’s architecture fulfill our requirements? Requirement Yes/No Comments 1) Non-rectangular raster Creates as many tables as there are Yes but rasters. 1000 rasters = 1000 tables coverage 2) Easy import/export Request manual table creation or No FME ($$$) 3) SQL functions & operators Yes Although limited on the raster type 4) Lossless vector/raster No conversion 5) Seamless vector/raster Really not designed for this… No spatial functions/operators 6) Out-DB Storage No Not really…
  • 15. PostGIS WKT Raster An Open Source project specifically designed to meet these requirements Requirement Yes/No Comments 1) Non-rectangular raster Into a single table. Yes coverage Yes Very similar to PostGIS shp2pgsql.exe & 2) Easy import/export pgsql2shp.exe (gdal2wktraster.py) ST_Width(), ST_Height(), ST_BandPixelType(), 3) SQL functions & operators ST_PixelSizeX(), ST_PixelSizeY(), ST_NumBands(), on the raster type Yes ST_BandNoDataValue(), ST_GDALGeoTransform(), ST_Resample(), ST_Clip(), ST_Reclass(), ST_MapAlgebra(), ST_AsJPEG(), ST_AsTIFF(), ST_AsPolygon(), etc… 4) Lossless vector/raster Every raster (or tile) of a single coverage has its Yes own georeference and hence can overlap other conversion rasters. ST_Area(), ST_SRID(), ST_Transform(), ST_Union(), 5) Seamless vector/raster AT_Accum(), ST_AsKML(), ST_AsSVG(), ST_Translate(), spatial functions/operators Yes ST_Scale(), ST_Intersection(), ST_Intersects(), ST_Within(), ST_PointOnSurface(), &&, etc… 6) Out-DB Storage Yes Only filepaths are stored in the database.
  • 16. PostGIS WKT Raster Status • Contributions - Initial code base developed by Sandro Santilli, funded by Steve Cumming (UL, Canada) and Tyler Erickson (Michigan Tech Research Institute) - Basic functions, python importer, overviews and regular tiling code: Mateusz Loskot (CadCorp, UK) - GDAL Driver foundation: Jorge Arevalo (Google Summer of Code spanish student) • Version Beta 0.1 to be released this winter. Will include: - gdal2wktraster.py importer - Overviews (multiresolution pyramids) support - Accessor Functions (ST_SRID(), ST_Width(), ST_Height(), ST_PixelSizeX(), ST_PixelSizeY(), ST_RotationX(), ST_RotationY(), ST_UpperLeftX(), ST_UpperLeftY(), ST_ESRIWorldFile(), ST_GDALGeoTransform(), ST_NumBands(), ST_BandPixelType(), ST_BandNoDataValue()) - Basic Seamless Overlay Functions (ST_Intersects(), ST_Intersections(), ST_AsPolygon(), ST_Envelope(), ST_Shape()) - Spatial operators identical to the one on the geometry type (&&, &<, etc…) - Out-DB raster registration with gdal2wktraster.py - Well documented web site (doc & wiki specs, http://trac.osgeo.org/postgis/wiki/WKTRaster) • We also need your help! You can provide developer time or funds…
  • 17. Introducing WKT Raster « Raster Objects » • The fact that every raster in a PostGIS WKT Raster table has its own georeference and attributes, and is thus independent of other rasters in the table, is a very interesting characteric of those raster objects. • Like vector geometries, raster objects: - can overlap - can change location - can represent individual objects with their own identity • Moreover, raster objects can be used to model real life objects better represented as small fields (like fires or fuzzy objects). • Very new type of GIS object
  • 18. Introducing WKT Raster Objects Raster Objects vs Other GIS Objects • Point and Line Coverages • Polygon Coverages - Objects represent a constant surface with an identity and properties (like an object in a OO context) • Raster Object Coverages - Constant Raster Objects (categorical) Objects represent a constant surface with an identity and properties (like a feature or an object) Better modelled as polygon, but modelled as raster because they are better processed using existing raster algorithms (eg. landcover, basin) E.g.: land use; land cover; traditional raster objects that should overlap but can’t because they are in raster format (ex. buffers, animal territories) - Variable Raster Objects (field) Objects represent a variable field that have an identity and properties Generally modelised as a unique raster and difficult to model as polygons E.g.: fire, fuzzy objects (lakes, land cover, forest stands, soil), area of influence, animal territories • Traditional Raster Coverages - Represent a variable field with different values (no unique identity or other properties) - E.g.: elevation, climate, etc…
  • 19. Summary • The Canadian Spatial Data Foundry should facilitate, via a web service, GIS intersection operations over large-scale ecological datasets (vector & raster) • Oracle GeoRaster does not provide a good integration between raster and vector layer • PostGIS WKT Raster aims to provide such an integration - Support non-rectangular raster coverages - Lossless conversion between raster & vector layers - Seamless operators & functions on raster & vector types - Storage of raster outside the DB - Easy import/export similar to shp2pgsql.exe - We need your help! • WKT Raster introduces a new kind of GIS raster objects that are useful for modelling: - categorical features needing raster algorithms - fuzzy objects requiring their own identities