julius.g (3) [Avatar] Offline
#1
Hi,

A few things from listing 2.14 have me stumped, now going on a few days. Below is the code snippet of interest (I've added comments to help me know what each of those parameters is supposed to mean)

ST_MakeEmptyRaster(
	90, -- width 
	45, -- height
	(x-2) * 90, -- upperleftx
	(2-y) * 45, -- upperlefty
	1, -- scalex
	-1, -- scaley
	0, -- skewx
	0, -- skewx
	4326 -- srid
)


1. lines 4 and 5 use 2. Why? I thought numbering on the axis would start either from '0' or '1' and increase by 1 to the next value. But seeing "2" in the formula threw me off & I'm wondering why - maybe my initial assumption is invalid and in this example, the numbering increases by '2'

2. This is more of a request to confirm my understanding of the titled "Pixel Scale." From these sentences,
A raster’s pixel cell numbering always starts at the top-left corner of the tile rectangle, whereas when we talk about coordinate space we generally start numbering from the bottom-left corner. A negative Y pixel scale means increasing pixel row cell numbers correspond to decreasing Y spatial coordinates, and a positive X pixel scale means increasing column cell numbers correspond to increasing X coordinates

I imagined line 4 and 5 to be:
(x) * 90, -- upperleftx
(-y) * 45, -- upperlefty

If I look "down" from the top-left corner and follow each row until I reach to the bottom-left corner (pixel numbering convention), the -Y value becomes bigger and bigger. But if I change positions and look "up" from the bottom-left corner (in coordinate space), Y value becomes smaller and smaller.

3. The example mentioned from the start of this section was that of modelling Manhattan (pp.54, 56 in PDF). I thought this was the raster we were going to make and was surprised by a wholly new example.

4. Using the Manhattan example, what would the values be for scalex and scaley ? I assumed that scalex = 274 and scalex = -80 but the last sentence uses the word "scale" in a different way and threw me off again ;(

For the Manhattan raster example, the width of each pixel represents 274 meters, so it would be said to have an X scale of 1:274. Similarly, the Y scale is 1:80. You often encounter scales on a printed map. If you use a unit grid of 1 mm to map Manhattan, then each block would occupy 274 by 80 mm on paper, and the map could be said to have a 1:1000 scale.


a. Does "it" in the above paragraph refer to the whole raster or to one pixel ?
b. Can you please confirm if these figures are valid when modelling the Manhattan example: scalex = 274 and scalex = -80

5. If I wanted to continue with the Manhattan example and model it with 255 city blocks, would the following assumptions and code snippet be valid ?
* One Raster tile for Manhattan, which is made up of 255 pixels. Width of raster is 15 pixels; height of raster is 17 pixels.
* Each pixel has width 274 metres and heigh of 80 metres (taken from page 56 of PDF)
* The pixel's X scale of 1:274. Similarly, the Y scale is 1:80 (taken from page 56 of PDF)

ST_MakeEmptyRaster(
	15, -- width 
	17, -- height
	(x-1) * 15, -- upperleftx
	(1-y) * 17, -- upperlefty
	274, -- scalex
	-80, -- scaley
	0, -- skewx
	0, -- skewx
	4326 -- srid
)



P.S. I apologise if these questions seem basic. I've recently started to learn about GIS/PostGIS. And this book is a big help.

Thanks,
Julius