Opened 5 years ago

Closed 3 months ago

#2249 closed enhancement (fixed)

[raster] Implement ST_MakeEmptyCoverage

Reported by: dzwarg Owned by: dzwarg
Priority: medium Milestone: PostGIS 2.4.0
Component: documentation Version: trunk
Keywords: raster Cc: ainomieli

Description

Make a helper method that creates an empty coverage.

An empty coverage is a set of rasters that are regularly tiled that cover the entire pixel area of the coverage, tiling based on the tilewidth/tileheight.

Attachments (3)

makeemptycoverage.patch (3.1 KB) - added by dzwarg 5 years ago.
Implementation of non-rotating ST_MakeEmptyCoverage()
makeemptycoverage.2.patch (5.3 KB) - added by dzwarg 5 years ago.
Implementation of rotatable ST_MakeEmptyCoverage()
makeemptycoverage-docs.patch (4.6 KB) - added by ainomieli 3 years ago.
preliminary docs

Download all attachments as: .zip

Change History (18)

Changed 5 years ago by dzwarg

Attachment: makeemptycoverage.patch added

Implementation of non-rotating ST_MakeEmptyCoverage()

comment:1 Changed 5 years ago by dzwarg

Status: newassigned

To handle rotation:

Create a single fake raster with as many cells as tiles in the coverage. Iterate over the x,y dimensions of that raster, and use the ULX and ULY of each fake raster pixel to generate a new empty raster with proper ULX and ULY values for the rotated component tiles in the coverage.

Changed 5 years ago by dzwarg

Attachment: makeemptycoverage.2.patch added

Implementation of rotatable ST_MakeEmptyCoverage()

comment:2 Changed 4 years ago by pramsey

Milestone: PostGIS 2.2.0
Type: defectenhancement
Version: 2.0.xtrunk

comment:3 Changed 4 years ago by robe

Component: postgisraster

comment:4 Changed 3 years ago by strk

This is needed for ST_CreateOverviews (#2247)

comment:5 Changed 3 years ago by strk

I've taken a look at the function signature in the latest patch and got a bit scared :) I imagine a coverage creation as two steps:

  1. Creation of the table that would represent the coverage configuration
  2. Population of the coverage

The first step could be similar to AddRasterColumn?, that is it only creates a structure, w/out inserting the data.

The way I'd call such a coverage-creation function would be by passing it:

Mandatory:

  1. The spatial extent to be covered by the coverage
  2. The pixel size in geographical units (the scale)

Optional:

  1. SRID. Unconstrained if not given. [ok, maybe this could be mandatory]
  2. The max size of coverage tiles in pixels. Unconstrained if not given.

I see this function instead creates a whole set of empty tiles, which is possibly a big waste of time as you probably want to later modify those tiles to have actual data in them...

Also for a big coverage it could be very easy to end up out of memory.

comment:6 Changed 3 years ago by strk

Comments about this @dustymugs ?

comment:7 Changed 3 years ago by strk

A pointer to the manual page explaining that the whole resultset from a SET-RETURNING plpgsql function is hold in memory (possibly flushed to disk temporarely) until completed: http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

comment:8 in reply to:  5 Changed 3 years ago by pracine

Replying to strk:

I've taken a look at the function signature in the latest patch and got a bit scared :) I imagine a coverage creation as two steps:

  1. Creation of the table that would represent the coverage configuration
  2. Population of the coverage

The first step could be similar to AddRasterColumn?, that is it only creates a structure, w/out inserting the data.

The way I'd call such a coverage-creation function would be by passing it:

Mandatory:

  1. The spatial extent to be covered by the coverage
  2. The pixel size in geographical units (the scale)

Optional:

  1. SRID. Unconstrained if not given. [ok, maybe this could be mandatory]
  2. The max size of coverage tiles in pixels. Unconstrained if not given.

I see this function instead creates a whole set of empty tiles, which is possibly a big waste of time as you probably want to later modify those tiles to have actual data in them...

Also for a big coverage it could be very easy to end up out of memory.

ST_MakeEmptyCoverage() should create EMPTY rasters tiles, thus having no bands and hence almost no data. It is useful for any query that want a set of reference tiles to recreate a raster coverage from an existing one or from a vector coverage (rasterizing). You use, for example, to create on the fly an empty raster table in the FROM geomtable, (SELECT ST_MakeEmptyCoverage() rast) that is used only as reference by function in the SELECT. Many functions have a reference raster as parameter from which they borrow alignment information.

comment:9 Changed 3 years ago by strk

Good point, I hadn't considered the rasters were empty ! Then I guess the only thing missing here is documentation in the manual.

comment:10 Changed 3 years ago by ainomieli

Here is boilerplate for creating tile set with bounds (:x0, :y0, :x1, :y1) and grid dimensions (:width, :height):

SELECT cell FROM ST_MakeEmptyCoverage(
  1, 1, -- tile width, tile height
  :width, :height, -- grid columns, grid rows
  :x0, :y0, -- upperleftx, upperlefty
  (:x1 - :x0)/(:width)::float, -- scalex
  (:y1 - :y0)/(:height)::float, -- scaley
  0., 0., -- skewx, skewy
  4326 -- srid
  ) cell;
  • (:x0, :y0) is the upper left corner
  • (:x1, :y1) is the lower right corner
  • :width is the number of columns in the grid
  • :height is the number of rows in the grid

Changed 3 years ago by ainomieli

preliminary docs

comment:11 Changed 2 years ago by robe

Milestone: PostGIS 2.2.0PostGIS 2.3.0

comment:12 Changed 16 months ago by robe

Milestone: PostGIS 2.3.0PostGIS 2.4.0

I hate pushing this but I don't have time to test it out and giving the patch is so old, not sure how it plays with our current code.

comment:13 Changed 3 months ago by robe

Component: rasterdocumentation

comment:14 Changed 3 months ago by robe

Cc: ainomieli added

ainomieli,

If you are still around, can you give me your name as you want to appear in credits?

Thanks, Regina

comment:15 Changed 3 months ago by robe

Resolution: fixed
Status: assignedclosed

In 15562:

ST_MakeEmptyCoverage (David Zwarg, ainomieli)
Closes #2249 for PostGIS 2.4.0

Note: See TracTickets for help on using tickets.