Huayi Wu, Haoyue Jiao, Shuyang Hou, Jianyuan Liang, Zhangxiao Shen, Anqi Zhao, Yaxian Qing, Fengying Jin, Xuefeng Guan, Zhipeng Gui
Automated geospatial code generation using large language models (LLMs) faces challenges in requirement parsing, syntax adaptation, path retrieval, code validation, and spatial recognition, often leading to ‘code hallucinations.’ To address these, we introduce GeoColab, the first multi-agent framework for geospatial code generation. It defines three roles—product manager, algorithm engineer, and programmer—operating under standardized procedures. GeoColab integrates a knowledge support mechanism and retrieval-augmented generation (RAG), utilizing 8,729 function syntax documents, 2,732 datasets, 115 external APIs, 94 projection methods, and 3,837 CRS transformation entries, all stored and accessed via a document management system. We also present the GeoCodes benchmark, with 25 explicit, 15 incomplete, and 10 open-ended tasks. Applied to seven mainstream LLMs, including GPT-4.5 and DeepSeek-V3-0324, GeoColab improves code executability, accuracy, and readability by 7.59%–26.09%, surpassing baselines like CodeCoT and ChatDev by up to 31.03%. Ablation studies show a 4.39%–9.30% performance drop without knowledge modules, highlighting their importance. GeoColab is open-sourced and supports local deployment, reducing technical barriers to geospatial programming and broadening LLMs' use in GIS.