PromptBase
Upgrade
Close icon
General
Home
Marketplace
Create
Hire
Login
Chat
Sell
Explore

Prompt Details

Model
(gemini-3.1-pro)
Token size
238
Example input
[GIS_Environment]: QGIS (PyQGIS) [Task_Description]: Load a vector layer, apply a simple symbology, generate a spatial layout map, add a legend, and export it as a PDF.
Example output
### 🌍 1. Spatial Logic & CRS Strategy The script will utilize the QGIS Python API (PyQGIS) to interact with the current project instance. It assumes the vector layer is already in a projected CRS (like UTM) suitable for printing. The script will programmatically create a `QgsPrintLayout`, compose the map extent to fit the layer, dynamically generate a legend based on the layer's symbology, and render the final output to a local PDF file. ### 📜 2. The Automation Script ```python import os from qgis.core import (QgsProject, QgsVectorLayer, QgsPrintLayout, QgsLayoutItemMap, QgsLayoutItemLegend, QgsLayoutExporter, QgsLayoutPoint, QgsLayoutSize) # 1. Load the Layer layer_path = "C:/gis_data/regions.shp" layer = QgsVectorLayer(layer_path, "Study Regions", "ogr") if not layer.isValid(): print("Layer failed to load!") else: QgsProject.instance().addMapLayer(layer) # 2. Create Layout project = QgsProject.instance() manager = project.layoutManager() layout = QgsPrintLayout(project) layout.initializeDefaults() layout.setName("Automated_Map_Layout") manager.addLayout(layout) # 3. Add Map Item map_item = QgsLayoutItemMap(layout) map_item.setRect(20, 20, 20, 20) map_item.attemptMove(QgsLayoutPoint(10, 10, 1)) map_item.attemptResize(QgsLayoutSize(200, 150, 1)) map_item.setLayers([layer]) map_item.zoomToExtent(layer.extent()) layout.addLayoutItem(map_item) # 4. Add Legend legend = QgsLayoutItemLegend(layout) legend.setTitle("Map Legend") legend.attemptMove(QgsLayoutPoint(220, 10, 1)) layout.addLayoutItem(legend) # 5. Export to PDF exporter = QgsLayoutExporter(layout) export_path = "C:/gis_data/output_map.pdf" exporter.exportToPdf(export_path, QgsLayoutExporter.PdfExportSettings()) print(f"Map successfully exported to {export_path}")
♊️ Gemini

Gis Geospatial Automation Expert

Add to Cart
Instant accessInstant access
Usage rightsCommercial use
Money-back guaranteeMoney‑back
By purchasing this prompt, you agree to our terms of service
GEMINI-3.1-PRO
Tested icon
Guide icon
4 examples icon
Free credits icon
Stop doing repetitive manual mapping tasks. This Principal GIS Developer prompt generates production-ready automation scripts (PyQGIS, ArcPy, GeoPandas, PostGIS) to automate spatial data analysis, bulk layer styling, and dynamic map layouts instantly.
...more
Added 3 hours ago
Report
Browse Marketplace