[gdal-dev] Python RasterizeLayer and gdal_rasterize

Ivan Lucena ivan.lucena at outlook.com
Wed Jul 24 12:38:34 PDT 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190724/e9527409/attachment.html>


More information about the gdal-dev mailing list