[QGIS-Developer] Reg: QgsCoordinateTransform not working on Linux

Prem Kumar prem.netgis at gmail.com
Thu May 27 05:57:33 PDT 2021


Hi Team,

Just wondering whether I'm missing something or a genuine bug, please
advise below.

All I am trying is, to take the geometry object in json format whose CRS is
in WGS84 (EPSG:4326) and transform the geometry to EPSG:3857 CRS and
eventually use it in further processing because rest of the processing is
in EPSG:3857 CRS.

I have written below code and it works like a charm on Windows 10 but it
doesn't transform the geometry on Linux. Please advise if there is anything
wrong or missing to add.
*Code Snippet for reproducing:*

from qgis.PyQt.QtCore import QVariant
from shapely.geometry import shape
import geojson,json
from qgis.core import
(QgsGeometry,QgsCoordinateReferenceSystem,QgsCoordinateTransform,QgsProject)
from shapely import speedups as sups
sups.disable()

in_geometry='[{"type": "LineString","coordinates":
[[-78.85338577199997,43.85845267000008],[-78.85593885699996,43.857924291000074]]}]'
geomjson = json.loads(in_geometry)
old_crs = QgsCoordinateReferenceSystem("EPSG:4326")
new_crs = QgsCoordinateReferenceSystem("EPSG:3857")
xtransform = QgsCoordinateTransform(old_crs, new_crs, QgsProject.instance())
for i, g in enumerate(geomjson):
    s = json.dumps(g)
    g1 = geojson.loads(s)
    shapely_geom = shape(g1)
    qgs_geom=QgsGeometry.fromWkt(shapely_geom.wkt)
    qgs_geom.transform(xtransform)
    print (qgs_geom)

*Output from Pycharm:*
C:\Qgis\apps\Python37\python.exe C:/_WORK/SERVICE/test_transform.py
<QgsGeometry: LineString (-8777918.77684544585645199
5443563.52439526654779911, -8778202.97550544328987598
5443481.85537817236036062)>

Process finished with exit code 0

*Output from Linux terminal:*
(gisenv) admin at rd-temp-server:~/gis_service$ python3 test_transform.py
Application path not initialized
Application path not initialized
<QgsGeometry: LineString (-78.85338600000000042 43.85845299999999725,
-78.85593900000000644 43.85792399999999702)>
(gisenv) admin at rd-temp-server:~/gis_service$

Thanks.
-Prem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210527/710f387b/attachment.html>


More information about the QGIS-Developer mailing list