| name | qgis-11-pyqgis-application-bootstrap-headless |
| description | Sub-skill of qgis: 1.1 PyQGIS Application Bootstrap (Headless) (+2). |
| version | 1.0.0 |
| category | engineering/gis |
| type | reference |
| scripts_exempt | true |
1.1 PyQGIS Application Bootstrap (Headless) (+2)
1.1 PyQGIS Application Bootstrap (Headless)
import sys
import os
os.environ["QT_QPA_PLATFORM"] = "offscreen"
from qgis.core import QgsApplication
qgs = QgsApplication([], False)
qgs.initQgis()
1.2 Well Locations from CSV (lat/lon)
from qgis.core import (QgsVectorLayer, QgsProject,
QgsCoordinateReferenceSystem)
uri = (
"file:///path/to/wells.csv"
"?delimiter=,"
"&xField=longitude"
"&yField=latitude"
"&crs=EPSG:4326"
)
layer = QgsVectorLayer(uri, "wells", "delimitedtext")
if not layer.isValid():
raise RuntimeError("Failed to load CSV layer")
QgsProject.instance().addMapLayer(layer)
1.3 Supported Input Formats
| Format | Driver | Use |
|---|
| GeoPackage (.gpkg) | GPKG | Preferred vector store |
| Shapefile (.shp) | ESRI Shapefile | Legacy vector |
| GeoJSON (.geojson) | GeoJSON | Web interchange |
| GeoTIFF (.tif) | GTiff | Raster standard |
| NetCDF (.nc) | netCDF | Metocean/bathymetry |
| KML (.kml) | KML | Google Earth exchange |
| CSV + lat/lon | delimitedtext | Point data import |