I found what seems to answer my question by @xunilk in this closed post: Filling polygons with points or polygons using PyQGIS?
I follow the example of @xunilk with some modifications to adapt to QGIS version 3.4. But at the end of the python scipt I have this error message: "NameError: name 'QgsMapLayerRegistry' is not defined".
In the autocompletion of the python console, there is no QgsMapLayerRegistry function.
{}button that enables you to format any highlighted code nicely. Please check out our short [tour] for more about how the site works. Thanks. – PolyGeo Oct 29 '18 at 23:36QgsProject.instance().addMapLayer(mem_layer). You said you made some modifications to adapt to QGIS3, but you should be aware there are numerous API breaking changes in version 3. If you have any other issues you should post your code so we can help you properly. – Ben W Oct 30 '18 at 02:05