[Gdal-dev] Incorrect blank raster example in the FAQ?

leaffan markus.reinhold at uni-jena.de
Mon Oct 5 17:39:58 EDT 2009

Hej again,

Even Rouault wrote:
> Selon "Simon (Vsevolod) Ilyushchenko" <simonf at simonf.com>:
> Yes, your proposal is better and deals with non-square pixel. So I've
> changed
> the wiki page accordingly. Thanks!

the consideration of non-squared pixels could have been easily be included
in the previous wiki example as well. All one would have had to do is
changing it the following way:

# setting pixel resolution (for example)
xres = 0.5
yres = 0.75

# calculating resulting raster size from extent and desired pixel size
# using math.ceil to make it a little bit bigger than actually necessary
tiff_width = int(math.ceil(abs(src_extent[0] - src_extent[1]) / xres))
tiff_height = int(math.ceil(abs(src_extent[3] - src_extent[2]) / yres))

# creating new raster layer
raster = gdal.GetDriverByName('GTiff')
dst_ds = raster.Create(tiff, tiff_width, tiff_height, 1, gdal.GDT_Byte)

# creating raster geo transform based on upper left corner and desired pixel
# resolution and assigning it to raster dataset
# now dealing with non-squared pixels
raster_transform = [src_extent[0], xres, 0.0, src_extent[3], 0.0, -yres]

I still beg to differ to that defining the dimensions of the resulting
raster dataset is the setting to be primarily adjusted when converting
vector to raster data. Aliasing and the general *accuracy* of the raster
representation are first and foremost influenced by the pixel resolution,
which in turns determines the size of my resulting dataset. When doing
vector to raster conversions in the past, I have never thought of how large
my result needs to be, but always questioned myself how to define the pixel
resolution to i.e. avoid nasty aliasing effects on diagonal lines.
But that's just my experience and opinion of course.


Dipl.-Kartograph Markus Reinhold

Chair of Geoinformatics, Geohydrology and Modeling
Friedrich-Schiller-University Jena
Löbdergraben 32
D - 07743 Jena

Phone.: (+49)(0)3641 / 9 488 65
E-Mail: markus.reinhold at uni-jena.de

View this message in context: http://n2.nabble.com/Incorrect-blank-raster-example-in-the-FAQ-tp3765775p3771824.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.

More information about the gdal-dev mailing list