#qgis #gis
from qgis.core import QgsVectorLayer, QgsSimpleMarkerSymbolLayer, QgsProject
Replace 'your_file_path.geojson' with the actual path to your GeoJSON file
file_path = 'C:\Hamid\stuttgart_hauptbahnhof.geojson'
Add the GeoJSON file to the map
layer = QgsVectorLayer(file_path, 'Stuttgart Hauptbahnhof', 'ogr')
Check if the layer is valid
if layer.isValid():
Set the point symbol properties
symbol_layer = QgsSimpleMarkerSymbolLayer.create({
'name': 'circle',
'size': '10',
'color': 'red',
'outline_width': '1',
'outline_color': 'black'
})
symbol = QgsMarkerSymbol()
symbol.changeSymbolLayer(0, symbol_layer)
Set the renderer symbol for the layer
layer.renderer().setSymbol(symbol)
Add the layer to the map
QgsProject.instance().addMapLayer(layer)
print(f"Layer '{layer.name()}' loaded successfully.")
else:
print(f"Failed to load layer from '{file_path}'.")
Негізгі бет Part 25: How to open GeoJSON file in QGIS (Manually and with Python)
No video
Пікірлер: 9