Ich habe ein Skript, das eine PDF -Datei von QGIS -Kopfless auf Ubuntu erzeugt. Der zweite Lauf desselben Skripts erzeugt ein korrektes PDF. Der zweite Lauf verwendet zwischengespeicherte Kacheln und keine Fehler, die Ocurne. Aber korrigieren Sie mich, wenn ich falsch liege. (Gleiches passiert beim Erzeugen einer PNG -Ausgabe) < /p>
Dies ist mein Skript: < /p>
Ich habe ein Skript, das eine PDF -Datei von QGIS -Kopfless auf Ubuntu erzeugt. Der zweite Lauf desselben Skripts erzeugt ein korrektes PDF. Der zweite Lauf verwendet zwischengespeicherte Kacheln und keine Fehler, die Ocurne. Aber korrigieren Sie mich, wenn ich falsch liege. (Gleiches passiert beim Erzeugen einer PNG -Ausgabe) < /p> Dies ist mein Skript: < /p> [code]import os os.environ["QT_QPA_PLATFORM"] = "offscreen" os.environ["QGIS_DISABLE_CACHE"] = "1"
import sys
from qgis.PyQt.QtGui import QColor from qgis.PyQt.QtXml import QDomDocument
# combine extents of all polygons combinedExtent = None for geom in polygons: if geom and not geom.isEmpty(): if combinedExtent is None: combinedExtent = geom.boundingBox() else: combinedExtent.combineExtentWith(geom.boundingBox())
# transform to project CRS if needed projectCrs = QgsProject.instance().crs() if layerCrs != projectCrs: tr = QgsCoordinateTransform(layerCrs, projectCrs, QgsProject.instance()) extentProj = tr.transformBoundingBox(combinedExtent) else: extentProj = combinedExtent
with open(templatePath) as f: templateContent = f.read() doc = QDomDocument() doc.setContent(templateContent) context = QgsReadWriteContext() layout.loadFromTemplate(doc, context)
mapItems = [item for item in layout.items() if isinstance(item, QgsLayoutItemMap)] if not mapItems: raise Exception("No map item found in layout!") mapItem = mapItems[0]
polygons = [f.geometry() for f in features if f.hasGeometry()] if not polygons: raise ValueError("No valid geometries found in features")
addMapboxLayer() geojsonLayer = loadLayer(inputJson) setSymbology(geojsonLayer) setProjectCrs() features = [f for f in geojsonLayer.getFeatures()] printPdf(geojsonLayer, features, printTemplatePath, outputFileName)
qgs.exitQgis()
if __name__ == "__main__": main() [/code] [b] Bearbeiten: [/b] Hier ist der Backtrace des Fehlers: [code]Thread 1 "python3" received signal SIGSEGV, Segmentation fault. 0x00007fffece36619 in QGraphicsItemPrivate::removeExtraItemCache() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5 (gdb) bt #0 0x00007fffece36619 in QGraphicsItemPrivate::removeExtraItemCache() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5 #1 0x00007fffece396d1 in QGraphicsItem::setCacheMode(QGraphicsItem::CacheMode, QSize const&) () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5 #2 0x00007fffee3a6b26 in QgsLayoutExporter::renderRegion(QPainter*, QRectF const&) const () from /lib/libqgis_core.so.3.40.9 #3 0x00007fffee3a7014 in QgsLayoutExporter::renderRegionToImage(QRectF const&, QSize, double) const () from /lib/libqgis_core.so.3.40.9 #4 0x00007fffee3a8129 in QgsLayoutExporter::renderPageToImage(int, QSize, double) const () from /lib/libqgis_core.so.3.40.9 #5 0x00007fffee3a8632 in QgsLayoutExporter::printPrivate(QPagedPaintDevice*, QPainter&, bool, double, bool) () from /lib/libqgis_core.so.3.40.9 #6 0x00007fffee3b23a3 in QgsLayoutExporter::exportToPdf(QString const&, QgsLayoutExporter::PdfExportSettings const&) () from /lib/libqgis_core.so.3.40.9 #7 0x00007fffdf477f89 in ?? () from /usr/lib/python3/dist-packages/qgis/_core.cpython-312-x86_64-linux-gnu.so #8 0x0000000000581a6f in cfunction_call (func=0x7fffdc22d760, args=, kwargs=) at ../Objects/methodobject.c:537 #9 0x00000000005492f5 in _PyObject_MakeTpCall (tstate=0xba6ac8 , callable=0x7fffdc22d760, args=, nargs=2, keywords=0x0) at ../Objects/call.c:240 #10 0x0000000000549d2d in _PyObject_VectorcallTstate (kwnames=, nargsf=, args=, callable=, tstate=) at ../Include/internal/pycore_call.h:90 #11 0x00000000005d68bf in _PyEval_EvalFrameDefault (tstate=tstate@entry=0xba6ac8 , frame=, frame@entry=0x7ffff7fb2020, throwflag=throwflag@entry=0) at Python/bytecodes.c:2706 #12 0x00000000005d4dab in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff7fb2020, tstate=0xba6ac8 ) at ../Include/internal/pycore_ceval.h:89 #13 _PyEval_Vector (kwnames=0x0, argcount=0, args=0x0, locals=0x7ffff7c0dbc0, func=0x7ffff7bee160, tstate=0xba6ac8 ) at ../Python/ceval.c:1683 #14 PyEval_EvalCode (co=co@entry=0x7ffff7b3dc30, globals=globals@entry=0x7ffff7c0dbc0, locals=locals@entry=0x7ffff7c0dbc0) at ../Python/ceval.c:578 #15 0x0000000000607fc2 in run_eval_code_obj (locals=0x7ffff7c0dbc0, globals=0x7ffff7c0dbc0, co=0x7ffff7b3dc30, #16 run_mod (mod=, filename=, globals=0x7ffff7c0dbc0, locals=0x7ffff7c0dbc0, flags=, arena=) at ../Python/pythonrun.c:1743 #17 0x00000000006b4393 in pyrun_file (fp=fp@entry=0xbab490, filename=filename@entry=0x7ffff79bdc50, start=start@entry=257, globals=globals@entry=0x7ffff7c0dbc0, locals=locals@entry=0x7ffff7c0dbc0, closeit=closeit@entry=1, flags=0x7fffffffda48) at ../Python/pythonrun.c:1643 #18 0x00000000006b40fa in _PyRun_SimpleFileObject (fp=fp@entry=0xbab490, filename=filename@entry=0x7ffff79bdc50, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffda48) at ../Python/pythonrun.c:433 #19 0x00000000006b3f2f in _PyRun_AnyFileObject (fp=0xbab490, filename=filename@entry=0x7ffff79bdc50, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffda48) at ../Python/pythonrun.c:78 #20 0x00000000006bbf45 in pymain_run_file_obj (skip_source_first_line=0, filename=0x7ffff79bdc50, program_name=0x7ffff7c0dcf0) at ../Modules/main.c:360 #21 pymain_run_file (config=0xb496a8 ) at ../Modules/main.c:379 #22 pymain_run_python (exitcode=0x7fffffffda3c) at ../Modules/main.c:629 #23 Py_RunMain () at ../Modules/main.c:709 #24 0x00000000006bba2d in Py_BytesMain (argc=, argv=) at ../Modules/main.c:763 #25 0x00007ffff7c991ca in __libc_start_call_main (main=main@entry=0x518bd0 , argc=argc@entry=4, argv=argv@entry=0x7fffffffdc88) at ../sysdeps/nptl/libc_start_call_main.h:58 #26 0x00007ffff7c9928b in __libc_start_main_impl (main=0x518bd0 , argc=4, argv=0x7fffffffdc88, init=, fini=, rtld_fini=, stack_end=0x7fffffffdc78) at ../csu/libc-start.c:360 #27 0x0000000000656a35 in _start ()
Ich versuche, das HTML -DIV -Element mit JavaScript in eine Wortdatei zu exportieren. Das DIV -Element enthält einige Texte und zwei Bilder. Ein Bild verwendet den absoluten Pfad und das andere Bild...
Ich erstelle einen QGIS -Plugin und verwende Python Pandas Bibliothek. Wie installiere ich die Pandas -Bibliothek in QGIS Python? Bitte helfen Sie mir!
Hallo, ich habe ein Python -Problem, wenn ich versuche, ein Plugin auf QGIS zu starten. def get_data_source_file_path(layer):
# get source path
provider = layer.dataProvider().name()
source_parts =...
Ich mache eine mit der ML -Modellierung integrierte Geospatial -Bewertung. Das Problem ist der Prozentsatz der sehr geringen Genauigkeit, da mehr Trainingsfunktionen zunehmen, und es wird niedriger....
Ich versuche, ein Projekt mit Intel RealSense D415 zu erstellen, das es mir ermöglicht, die Koordinate zu bestimmen, konventionell die Spitze meines Zeigefingers in Koordinaten basierend auf Aruco...