Skip to content

Instantly share code, notes, and snippets.

@agiudiceandrea
Last active January 7, 2021 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agiudiceandrea/95f203bfa0f5917290e882e8e8ccbe56 to your computer and use it in GitHub Desktop.
Save agiudiceandrea/95f203bfa0f5917290e882e8e8ccbe56 to your computer and use it in GitHub Desktop.
QGIS 3.4.5-9-Madeira
GEOS 3.7.0-CAPI-1.11.0
PROJ 5.2.0
SpatiaLite 4.3.0
from processing.tools import spatialite
db = spatialite.GeoDB(QgsDataSourceUri('dbname=\'C:/Users/Andrea/test.sqlite\' table=\'test\'(geometry) sql='))
cur=db.con.cursor()
db._exec_sql(cur, sql='select spatialite_version();')
cur.fetchone()[0]
'4.3.0'
db._exec_sql(cur, sql='select proj4_version();')
cur.fetchone()[0]
'Rel. 5.2.0, September 15th, 2018'
db._exec_sql(cur, sql='select geos_version();')
cur.fetchone()[0]
'3.7.0-CAPI-1.11.0 673b9939'
db._exec_sql(cur, sql='select lwgeom_version();')
cur.fetchone()[0]
'3'
db._exec_sql(cur, sql='select st_area(st_geomfromtext(\'POLYGON ((20.13293641 59.95688345, 26.94617837 60.47397663, 29.74782155 62.56499443, 27.45254202 68.70650340, 23.75771765 68.24937206, 25.42698984 65.27444593, 21.51545237 63.10353609, 21.40562760 61.12318104, 19.41123592 60.40477513, 20.13293641 59.95688345))\') ,true);')
cur.fetchone()[0]
251199344354.4308
db._exec_sql(cur, sql='select st_perimeter(st_geomfromtext(\'POLYGON ((20.13293641 59.95688345, 26.94617837 60.47397663, 29.74782155 62.56499443, 27.45254202 68.70650340, 23.75771765 68.24937206, 25.42698984 65.27444593, 21.51545237 63.10353609, 21.40562760 61.12318104, 19.41123592 60.40477513, 20.13293641 59.95688345))\') ,true);')
cur.fetchone()[0]
2578086.2023619814
geom=QgsGeometry.fromWkt("POLYGON ((20.13293641 59.95688345, 26.94617837 60.47397663, 29.74782155 62.56499443, 27.45254202 68.70650340, 23.75771765 68.24937206, 25.42698984 65.27444593, 21.51545237 63.10353609, 21.40562760 61.12318104, 19.41123592 60.40477513, 20.13293641 59.95688345))")
d = QgsDistanceArea()
d.measureArea(geom)
45.258471520759485
d = QgsDistanceArea()
d.setEllipsoid('WGS84')
True
d.measureArea(geom)
249566957499.75446
d.measurePerimeter(geom)
2578086.2023619823
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment