In a python script, I can't access the geometry of my tables :

SQL_req = 'SELECT id_parcel, id_melba FROM parcels, network WHERE st_intersects(parcels.geometry, network.geometry)'
grass.write_command("db.select", input='-', stdin=SQL_req, stdout = DEVNULL, stderr = DEVNULL)

gives :

DBMI-SQLite driver error:
Error in sqlite3_prepare():
SELECT id_parcel, id_melba FROM parcels, network WHERE st_intersects(parcels.geometry, network.geometry)
no such column: parcels.geometry

Shapefiles were imported with v.in.ogr and other sql requests are correctly ending. That's when I try to use spatial functions that it don't work.

Any suggest or example?

1 Answer 1


In the GRASS vector model, there is no geometry stored in the SQL database. The backend SQL database is for attributes only. Geometry is stored in a special set of GRASS files.

You should be looking at the native GRASS modules for selection/intersection. etc such as v.overlay or v.select.

  • Or, use GRASS to export to shapefile, and load the shapefile directly in Python to work with the geometry.
    – mankoff
    Commented Apr 26, 2017 at 20:50
  • Thanks! What do you mean by loading shapefile directly?
    – Christine
    Commented Apr 27, 2017 at 7:57
  • I'd like to use spatial functions. For example : st_split because I didn't find a module in GRASS that splits polygons with a polyline.
    – Christine
    Commented Apr 27, 2017 at 8:12
  • Loading the shapefile directly into python means using pyshp or gdal python bindings, not GRASS.
    – mankoff
    Commented Apr 27, 2017 at 13:39
  • Regarding spliting polygons in GRASS, Did you see the answer posted here: [gis.stackexchange.com/questions/237818/…
    – Micha
    Commented Apr 28, 2017 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.