Skip to content

Instantly share code, notes, and snippets.

@pigreco
Created February 25, 2021 19:17
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 pigreco/f0729f630a7298f13f62223a14d47cf1 to your computer and use it in GitHub Desktop.
Save pigreco/f0729f630a7298f13f62223a14d47cf1 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pigreco
Copy link
Author

pigreco commented Feb 25, 2021

query utilizzata:

UPDATE utmzones_area
 SET (area_spatialite_5_true,area_spatialite_5_false) = 
(
	select st_area(geom, true) as area_spatialite_5_true,
 	       st_area(geom, false) as area_spatialite_5_false
 	from utmzones_area t
 	where t.pk = utmzones_area.pk
)

image

OSGeo4W64 WIN 10

image

version

SELECT 
sqlite_version() as sqlite_version,
spatialite_version() as spatialite_version,
proj_version() as proj_version,
geos_version() as geos_version,
rttopo_version() as rttopo_version,
libxml2_version() as libxml2_version,
spatialite_target_cpu() as spatialite_target_cpu

image


🔗 https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html

@pigreco
Copy link
Author

pigreco commented Mar 24, 2021

image

image

image

@jratike80
Copy link

In some screenshots the geometry field is "geom", in the failing case "geometry". Are you sure that you are using the correct name?

@pigreco
Copy link
Author

pigreco commented Mar 24, 2021

In some screenshots the geometry field is "geom", in the failing case "geometry". Are you sure that you are using the correct name?

QGIS sees the name of the geometry field in the case of a virtual layer,geom in the case of a sqlite table

virtual layer

image

sqlite

image

@jef-n
Copy link

jef-n commented Mar 24, 2021

refs qgis/QGIS#41890

Trying following with plain spatialite to verify it's not an qgis issue:

SELECT load_extension('mod_spatialite');
SELECT InitSpatialMetadata(1);
SELECT 
sqlite_version() as sqlite_version,
spatialite_version() as spatialite_version,
proj_version() as proj_version,
geos_version() as geos_version,
rttopo_version() as rttopo_version,
libxml2_version() as libxml2_version,
spatialite_target_cpu() as spatialite_target_cpu;
SELECT ImportGeoJSON('utmzones_area.geojson', 'utmzones_area', 'geom', 1, 4326);
UPDATE utmzones_area
 SET (area_spatialite_5_true,area_spatialite_5_false) =
(
        select st_area(geom, true) as area_spatialite_5_true,
               st_area(geom, false) as area_spatialite_5_false
        from utmzones_area t
        where t.pk = utmzones_area.pk
);

On osgeo4w testing:

D:\TEMP\osgeo4w-2>set SPATIALITE_SECURITY=relaxed
D:\TEMP\osgeo4w-2>sqlite3 <check.sql

1
3.35.2|5.0.1|Rel. 8.0.0, March 1st, 2021|3.9.1-CAPI-1.14.2|1.1.0-dev|2.9.10|Windows_64bit
1204
RTTOPO error: ptarray_area_spheroid: cannot handle ptarray that crosses equator

[62x in total]

And on debian unstable (older sqlite3, older PROJ, slightly different RTTOPO):

$ SPATIALITE_SECURITY=relaxed sqlite3 <check.sql

1
3.34.1|5.0.1|Rel. 7.2.1, January 1st, 2021|3.9.0-CAPI-1.16.2|1.1.0|2.9.10|x86_64-linux-gnu
1204
RTTOPO error: ptarray_area_spheroid: cannot handle ptarray that crosses equator

[62x in total]

so it could be an upstream issue - in rttopo maybe?

@jef-n
Copy link

jef-n commented Mar 24, 2021

interesting - what does 3.9.1-CAPI-1.14.2 vs 3.9.0-CAPI-1.16.2 mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment