Skip to content

PostGIS Rasters Support

rochoa edited this page Oct 1, 2014 · 1 revision

Roadmap

Tiler support

  1. Install Mapnik with PostGIS Raster plugin support (2.3.x + pull-request) https://github.com/mapnik/mapnik/pull/2288

  2. Allow specifying column name in grainstore: https://github.com/CartoDB/grainstore/issues/92 (already pushed to master branch, not in any official release)

  3. Allow specifying column type in grainstore:

    See https://github.com/CartoDB/grainstore/issues/93

    READY https://github.com/strk/grainstore/tree/pgraster | https://github.com/CartoDB/grainstore/pull/95

    Example https://github.com/strk/grainstore/blob/pgraster/test/mml_builder_multilayer.js#L150-L158

  4. Allow specifying band number in grainstore. When using a raster-colorizer style the mapnik plugin must be configured to specify the band number to use for the raster data. Not specifying a band number would result in the plugin interpreting the data as a grayscale value.

    READY https://github.com/strk/grainstore/tree/pgraster | https://github.com/CartoDB/grainstore/pull/95

    Example https://github.com/strk/grainstore/blob/pgraster/test/mml_builder_multilayer.js#L198-L211

  5. Allow specifying column name in MapConfig: https://github.com/CartoDB/Windshaft/issues/191 (pushed in a "pgraster" branch already)

  6. Allow specifying column type in MapConfig: https://github.com/CartoDB/Windshaft/issues/190

  7. Allow specifying band number in MapConfig

Importer support

  1. Create raster overviews on import The importer should find out how many overviews to create, based on the original raster size. This is the -l 2,4,8,... switch of raster2pgsql. See Automatic raster overviews

  2. Set raster constraints on import This is the -C switch of raster2pgsql, constraints are needed to get to know the scale of each available overview

  3. Remove tiles only composed by NODATA values

    DON'T as this has 2 drawbacks: (1) users won't have a place to write new data into (2) adding visual interpretation of NODATA values would leave gaps on the map.

  4. Ensure rasters are projected to webmercator before import. NOTE: raster2pgsql would need to be passed rasters that are already in webmercator.

    Example gdalwarp -t_srs epsg:3857 raster.tif raster-wm.tif

  5. Ensure rasters are perfectly aligned to the webmercator grid before import. This includes scaling and padding. NOTE: a slightly higher resolution scale is to be preferred over a slightly lower one. See Aligning Rasters to Webmercator grid

  6. Import raster in tiles of 128x128, defining constraints and adding indexes. Example:

    raster2pgsql -t 128x128 -C -I -Y -s 3857 -l 2,4,8,16 HYP_HR-wm-al.tif.

  7. For single-band rasters, create indexes on min/max values. Doing so would greatly speedup the queries to fetch min/max pixel values for use by a raster colorizer wizard:

    select min( min(st_summarystats(rast,1)) ),
           max( max(st_summarystats(rast,1)) ) from hyp_1250m;
    

    This could maybe be done lazily by the wizard on a as-needed basis.

    ** Example ** create index on hyp_1250m ( min(st_summarystats(rast,1)) ); create index on hyp_1250m ( max(st_summarystats(rast,1)) );

User database model

  1. Grant SELECT on raster_columns and raster_overviews views to public

    See http://trac.osgeo.org/postgis/ticket/2905

  2. Have GRANTS on raster overview tables follow grants on main tables

    If a user sets a raster table to public, then all its overviews should become public too

Map editor user interface

  1. Recognize raster columns in user tables, creating maps accordingly

  2. Implement wizards for raster styling - includes recognizing if a raster has to be threated as containing RGB(A), Grayscale(A) or Data, see https://github.com/mapnik/mapnik/wiki/RFC:-Raster-color-interpretation

Clone this wiki locally