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

Even Rouault even.rouault at mines-paris.org
Mon Oct 5 18:10:09 EDT 2009


Selon leaffan <markus.reinhold at uni-jena.de>:

I actually missed your first post before changing the example, but your
arguments make sense. You're free to improve the page with your variant also :
it's a wiki !

Dimensions, spatial extent and resolutions are all linked between them, so there
are different point of views possible like the various gdalwarp options show :
-tr to set the resolution, or -ts to set the output size.

>
> 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]
> dst_ds.SetGeoTransform(raster_transform)
>
> 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.
> Regards,
> Markus
>
> --
>
> ********************************************************
> Dipl.-Kartograph Markus Reinhold
>
> Chair of Geoinformatics, Geohydrology and Modeling
> Friedrich-Schiller-University Jena
> Löbdergraben 32
> D - 07743 Jena
> Germany
>
> 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.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list