[gdal-dev] Python RasterizeLayer and gdal_rasterize
Kai Mühlbauer
kai.muehlbauer at uni-bonn.de
Wed Jul 24 13:05:05 PDT 2019
Hi Ivan,
For my application I also had to set the geotransform of the output raster. Just in case you might find it useful, here is the link to my dump_raster function.
https://github.com/wradlib/wradlib/blob/81e41376088c0ad5551c7b7b7eca4423d79b89ec/wradlib/zonalstats.py#L298
HTH,
Kai
Am 24. Juli 2019 21:38:34 MESZ schrieb Ivan Lucena <ivan.lucena at outlook.com>:
>Even, Kai,
>
>Thank you both for your reply.
>
>Adding a band.FlushCache() did not fixed the problem but it was a good
>point anyway. Thanks Kai.
>
>I tried to use the gdal.Rasterize() instead of gdal.RasterizeLayer()
>without success. There example on autotest varies quit a bit and I
>could not match one that works.
>
>The geojson and geotiff files have the exactly same SRS (EPSG:4326) and
>they overlap perfectly fine on QGIS. But it seems like the issue might
>be related to SRS anyway.
>
>Running the script from the Spyder IDE I was missing a warning message
>that now I can see by running "python script.py" on command line:
>
>Warning 1: Failed to fetch spatial reference on layer MEMORY_LAYER to
>build transformer, assuming matching coordinate systems.
>
>If I understood what Even said, I could fix that issue before calling
>gdal.RasterizeLayer() or use gdal.Rasterize() with the a transformation
>operation to fix the problem.
>
>I am going to work on that. Thank you again so very much,
>
>Ivan
>
>
>
>________________________________
>From: Even Rouault <even.rouault at spatialys.com>
>Sent: Wednesday, July 24, 2019 10:57 AM
>To: gdal-dev at lists.osgeo.org <gdal-dev at lists.osgeo.org>
>Cc: Ivan Lucena <ivan.lucena at outlook.com>
>Subject: Re: [gdal-dev] Python RasterizeLayer and gdal_rasterize
>
>Ivan,
>
>what comes to mind is a SRS mismatch issue. From what I can see
>gdal.RasterizeLayer() takes a pfnTransformer / pTransformArg for that,
>but I'm
>not sure if they are probably mapped to SWIG to something practical.
>
>You might try instead with the gdal.Rasterize() "utility as a C
>function" that
>is higher level and should take care of that automagically
>
>usage examples in autotest/utilities/test_gdal_rasterize_lib.py
>
>Even
>
>--
>Spatialys - Geospatial professional services
>http://www.spatialys.com
--
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190724/99264b79/attachment.html>
More information about the gdal-dev
mailing list