Skip to content
AI Agent
QGIS
Comparison

ArcPy vs PyQGIS: Differences and Code Side by Side

Published

Map of Bordeaux Métropole. 19 of 28 communes are shaded light blue, the other 9 are white. Orange bands follow the main roads, and 657 dark school points cover the urban core. Labels mark Bordeaux, Mérignac, Pessac and Ambès.
The output of the four PyQGIS tasks in this post, run on OpenStreetMap data for Bordeaux Métropole: a 100 m buffer, a selection by population, a spatial join and an export. Ambès, at the top, stays white with 3,207 people. OSM, ODbL, 22 October 2026.

ArcPy is Esri's Python package for ArcGIS Pro: it needs ArcGIS Pro installed and licensed, on Windows. PyQGIS is the Python interface to QGIS, free under the GPL, on Windows, macOS and Linux. Both call geoprocessing tools from Python, and most scripts translate tool by tool: arcpy.analysis.Buffer() becomes processing.run("native:buffer").

I ran every PyQGIS snippet below on OpenStreetMap data for Bordeaux Métropole. The ArcPy side follows Esri's documentation and was not run, since ArcGIS Pro does not install on a Mac. The surprise was not the syntax: it was four places where a script moved from one to the other gives a wrong answer without an error.

The two at a glance

ArcPyPyQGIS
What it isPython site package for ArcGIS ProPython bindings for QGIS
CostComes with ArcGIS Pro, from $700 a year in the Esri US storeFree, part of every QGIS install
Runs onWindows 11 or Windows ServerWindows, macOS and Linux
Calling a toolOne function per tool, arcpy.analysis.Buffer(...)One call with a tool ID, processing.run("native:buffer", {...})
OptionsKeywords such as "NEW_SELECTION"Named parameters, some as numbers such as "METHOD": 0
Distance unitIn the string, "100 Meters"The unit of the layer's CRS
Packagesconda environments, arcgispro-py3 by defaultThe Python that ships with QGIS

Four tasks side by side

The data: the 28 communes of Bordeaux Métropole, its 657 schools and 4,433 segments of motorway, trunk, primary and secondary road, all from OpenStreetMap, saved as GeoPackages in Lambert-93 (EPSG:2154, metres). The ArcPy lines assume layers with the same names in the current map. The PyQGIS lines use file paths, or the communes layer of the open project.

1. Buffer

# ArcPy
import arcpy

arcpy.analysis.Buffer("roads", "C:/data/output.gdb/roads_buffer", "100 Meters")
# PyQGIS
import processing

processing.run("native:buffer", {
    "INPUT": "data/roads.gpkg",
    "DISTANCE": 100,
    "OUTPUT": "data/roads_buffer.gpkg",
})

On my run: 4,433 buffers in 0.5 seconds. ArcPy reads the unit from the string, and on data in a geographic coordinate system it builds geodesic buffers when you give a linear unit. In QGIS, DISTANCE is in the units of the layer's CRS, which is the first trap below.

2. Select by attribute

# ArcPy
arcpy.management.SelectLayerByAttribute("communes", "NEW_SELECTION", "population > 10000")
# PyQGIS
from qgis.core import QgsProject
import processing

communes = QgsProject.instance().mapLayersByName("communes")[0]
processing.run("qgis:selectbyexpression", {
    "INPUT": communes,
    "EXPRESSION": 'to_int("population") > 10000',
    "METHOD": 0,  # 0 = new selection
})

On my run: 19 of the 28 communes selected, in 4 milliseconds. ArcPy takes an SQL where clause. QGIS takes a QGIS expression, with field names in double quotes and text values in single quotes. The to_int() is there because OpenStreetMap stores population as text, the third trap below. On a numeric field, '"population" > 10000' is enough. To get a new layer instead of a selection, use native:extractbyexpression with the same expression and an OUTPUT.

3. Spatial join

# ArcPy
arcpy.analysis.SpatialJoin(
    "schools", "communes", "C:/data/output.gdb/schools_communes",
    join_operation="JOIN_ONE_TO_ONE",
    join_type="KEEP_ALL",
    match_option="INTERSECT",
)
# PyQGIS
import processing

processing.run("native:joinattributesbylocation", {
    "INPUT": "data/schools.gpkg",
    "JOIN": "data/communes.gpkg",
    "PREDICATE": [0],  # 0 = intersect
    "JOIN_FIELDS": ["name"],
    "METHOD": 1,  # 1 = first match only
    "PREFIX": "commune_",
    "OUTPUT": "data/schools_communes.gpkg",
})

On my run: all 657 schools got their commune, in 75 milliseconds. The two handle several matches differently. ArcPy's one-to-one join merges the matching features with field map rules and adds a Join_Count field. QGIS method 1 keeps the first match and method 2 the one with the largest overlap. Both layers have a name field, so the prefix keeps them apart. Our spatial join guide times the other join types.

4. Export to a new file

# ArcPy
arcpy.conversion.ExportFeatures("roads", "C:/data/output.gdb/roads_copy")
# PyQGIS
import processing

processing.run("native:savefeatures", {
    "INPUT": "data/roads.shp",
    "OUTPUT": "data/roads_copy.gpkg",
    "LAYER_NAME": "roads",
})

On my run: 4,433 rows from a shapefile to a GeoPackage in 0.5 seconds. ArcPy writes a feature class, here into a file geodatabase. QGIS picks the format from the file extension.

Same tasks, counted

TaskArcPy linesPyQGIS linesValues you set, ArcPy / PyQGISPyQGIS time on Bordeaux
Buffer153 / 3505 ms
Select by attribute163 / 34 ms
Spatial join696 / 775 ms
Export152 / 3509 ms
Total92514 / 161.1 s

Lines are counted as printed above, without imports and comments. PyQGIS takes almost three times the lines, because each parameter sits on its own line in a dictionary. The number of decisions is close: 14 values in ArcPy, 16 in PyQGIS, and the two extra are the field list and the prefix of the join.

Where scripts break when you move them

A moved script that crashes is easy. These four ran without an error on my data and gave a wrong or surprising result. They are the checks I'd run on any script ported between the two.

Distance units come from the layer

ArcPy carries the unit in the string, so "100 Meters" means metres whatever the data. PyQGIS uses the unit of the layer's CRS. I ran the same buffer on a copy of the roads left in WGS 84 (EPSG:4326). It finished in half a second, no error, and produced buffers 100 degrees wide: the output reaches from longitude -100.8 to 99.5 and up to latitude 145, past the North Pole.

Two panels. Left, a world map with one orange disc centred on Bordeaux that covers Europe, Africa, the Atlantic and half of the Americas, labelled DISTANCE 100 = 100 degrees. Right, central Bordeaux with orange bands 100 m wide along the main roads, labelled DISTANCE 100 = 100 m, with a 500 m scale bar.
The same native:buffer call with DISTANCE 100. On the left the layer is in degrees and one road's buffer covers Europe, Africa and the Atlantic. On the right the layer is in Lambert-93 metres. Roads: OSM, ODbL. World outline: the world map bundled with QGIS.

The fix is one step before the buffer: native:reprojectlayer to a projected CRS in metres, as covered in what a CRS is.

A selection limits ArcPy tools, not processing.run

Esri's documentation says selections "limit the records that are processed by geoprocessing tools", so an ArcPy script that selects and then buffers works on the selection. In PyQGIS, passing the layer object ignores the selection. With the 19 large communes selected, native:buffer on communes returned 28 polygons. To work on the selection only, wrap the layer:

from qgis.core import QgsProcessingFeatureSourceDefinition

selected = QgsProcessingFeatureSourceDefinition(communes.id(), selectedFeaturesOnly=True)
processing.run("native:buffer", {
    "INPUT": selected,
    "DISTANCE": 500,
    "OUTPUT": "data/big_communes_500m.gpkg",
})

That returned 19 polygons in 64 milliseconds. In the tool window, the same switch is the Selected features only box under each input.

Numbers stored as text

OpenStreetMap stores population as text, and so do many CSV imports. On the GeoPackage, '"population" > 10000' selected all 28 communes, including Saint-Vincent-de-Paul with 997 people. The same expression on the same data as GeoJSON selected the right 19. My reading: for a GeoPackage, QGIS hands the filter to SQLite, which ranks any text above any number. With to_int("population") both formats give 19. Check the field type in the layer properties before you trust a comparison carried over from ArcPy.

Shapefile field names stop at 10 characters

Esri's documentation states it plainly: "Field names cannot be longer than 10 characters." QGIS writes shapefiles through GDAL, which applies the same rule its own way. My roads layer had 167 fields, 101 of them with longer names, and the writer renamed 113: colons became underscores, then names were cut and numbered. admin_level became admin_leve, maxspeed:type became maxspeed_t, cycleway:left became cycleway_2 and destination:ref became destinat10.

A script that reads "maxspeed:type" after a round trip through a shapefile finds nothing. Tools in ArcGIS and QGIS may shorten the same long name differently, so a ported script should read field names from the file, or skip shapefiles for a GeoPackage, which keeps them whole.

How I measured this

QGIS 3.44.8, headless PyQGIS, on a MacBook Air M4 with 16 GB, on 22 October 2026. The data is OpenStreetMap (ODbL) inside Bordeaux Métropole, downloaded through the Overpass API the same day: 28 communes, 657 schools as points, and 4,433 road segments, reprojected to Lambert-93 GeoPackages with one copy left in EPSG:4326. Each PyQGIS snippet ran as printed, from one script that first adds the communes layer to the project, the way it would sit in the Python console. Times are for the processing.run() call alone. The ArcPy snippets follow Esri's tool pages and were not run, and nothing here measures ArcGIS Pro's speed.

Licensing and cost

ArcPy ships in the Python environment of ArcGIS Pro and ArcGIS Server. Since Pro 2.7 you can add it to another conda environment, but Esri's documentation states that ArcGIS Pro must still be installed to use it. Outside the application, import arcpy raises RuntimeError: NotInitialized unless Pro can confirm a licence: Pro is open, you signed in with Sign me in automatically checked, or Pro is authorized to work offline.

The licence level matters inside a script too. In the Buffer tool, the Left and Right side options and the Flat end option need an Advanced licence. In the Esri US store, ArcGIS Pro costs $700 (Creator), $2,200 (Professional) or $4,200 (Professional Plus) a year. QGIS is licensed under the GNU GPL, version 2 or later, and PyQGIS comes with it at no cost.

Where your code runs

ArcPyPyQGIS
Inside the appPython window, ArcGIS NotebooksPython console (Plugins > Python Console), Processing scripts, plugins
Outside the apppropy myscript.py from the ArcGIS Pro Python environmentA standalone script that starts QgsApplication, or qgis_process from a terminal
Packagesconda, clone arcgispro-py3 before adding anyThe Python bundled with QGIS (OSGeo4W on Windows)

A standalone PyQGIS script has to know where QGIS is installed: the cookbook shows the PYTHONPATH and library paths to set on each system. To add a package in ArcGIS Pro, Esri advises cloning the default environment first:

conda create --clone arcgispro-py3 --name my_env --pinned

PyQGIS belongs to the QGIS version it came with, which matters since QGIS 4 moved to Qt 6: code that builds its own windows may need small fixes, as the PyQGIS guide shows.

Moving a script from ArcPy to PyQGIS

Rewrite it one tool at a time. For each ArcPy call, find the matching tool in the QGIS Processing Toolbox, fill in its window once, then open Advanced > Copy as Python Command. QGIS gives you the exact processing.run() line, with every parameter name. Then run the four checks above: units, selections, text fields, shapefile names.

The QGIS Count points in polygon tool window with kelurahan as polygons and schools as points. The Advanced menu at the bottom is open, with Copy as Python Command highlighted, above Copy as qgis_process Command, Copy as JSON and Paste Settings.
Copy as Python Command turns a tool set up by hand into the processing.run() line for your script, with numeric options such as METHOD already filled in.

When you know the task but not the API

We make AI Agent, so this section is about our own tool. You type the job in plain words in a panel inside QGIS, and it runs the matching QGIS tools in your open project. When no tool fits, it writes PyQGIS and waits for your approval before running it. It also refuses a distance given in degrees on a geographic CRS and names the metric CRS to use, which is the first trap above. You can ask it for a script to keep, too.

The AI Agent panel in QGIS. The request asks for a PyQGIS script that exports every vector layer of the project to its own GeoPackage in a chosen folder. The answer explains that the script opens a folder picker and does not overwrite existing files, followed by the code, which imports QgsProject and QgsVectorFileWriter.
Asked for a script, the agent writes PyQGIS that exports each vector layer of the project to its own GeoPackage.

Questions people ask

Is PyQGIS harder than ArcPy?

For calling tools, I find them close: the same number of decisions per task, written as a dictionary instead of arguments. PyQGIS feels harder at first because some options are numbers, such as 0 for intersect, where ArcPy uses words like "INTERSECT". Copy as Python Command removes most of that guesswork.

Can I run ArcPy in QGIS?

No. ArcPy needs ArcGIS Pro installed and licensed on the same Windows machine, and it runs from ArcGIS Pro's conda environment, not from the Python that QGIS uses. To run the same logic in QGIS, rewrite the calls with processing.run().

Can I convert an ArcPy script to PyQGIS?

Yes, by rewriting it tool by tool. Replace each ArcPy call with the matching Processing tool, copy its Python command from the tool's window, then check units, selections, text fields and shapefile field names. Input data usually carries over, since QGIS opens shapefiles and file geodatabases.

Does processing.run respect my selection?

Not when you pass the layer itself. Wrap it in QgsProcessingFeatureSourceDefinition(layer.id(), selectedFeaturesOnly=True). On my Bordeaux test that was the difference between 28 and 19 output features.

What is PyQGIS shows where Python runs in QGIS and tests chatbot code on six tasks, QGIS vs ArcGIS Pro compares the two programs on cost and Esri formats, and the spatial join guide times a large join in QGIS.

Do it in QGIS by asking for it

AI Agent carries out the task you describe, in your own QGIS project. Free, no card.

Try AI Agent for free

Keep reading

Map of Grenoble with a 150 metre orange zone along the main roads, 44 schools inside it in red, 103 others in blue, and a label per secteur such as Secteur 4, 17 of 33.
AI AgentQGISComparison

ArcGIS Tools in QGIS: 40 Equivalents, Named

40 ArcGIS Pro tools and their QGIS algorithm IDs. 14 need Advanced or a paid extension in ArcGIS Pro. A Grenoble workflow, run in QGIS in 0.8 seconds.

Lilien AugerLilien Auger
·
A dark card over a QGIS map of Lyon asks who pays for the AI. ArcGIS assistants: inside a licence of 700 dollars a year or more. Plugin plus your API key: your model bill. AI Agent by TerraLab, highlighted in green: model included, free plan.
AI AgentQGISComparison

ArcGIS AI Assistant vs QGIS AI Agents in 2026

Esri's AI assistants come free with a paid ArcGIS licence. In QGIS you pick: free plugins with your own API key, or an agent with the model included.

Yvann BarbotYvann Barbot
·