I'm creating a custom Qt app that uses pyqgis for showing data on maps. I have successfully created a map canvas that shows a world map from a WMS server.
Now I'd like to overlay data on this map. However, it seems that my vector layer interprets all coordinates in meters instead of lon/lat.
Here's more or less what I do to setup my data layer:
my_layer = QgsVectorLayer('Point', 'My Layer', 'memory') my_layer.setCrs(QgsCoordinateReferenceSystem(4326)) pr = my_layer.dataProvider() pr.addAttributes([QgsField('name', QVariant.String), QgsField('value', QVariant.Double)]) # add a point at lon=7.8, lat=47.5 feature = QgsFeature() feature.setGeometry(QgsGeometry.fromPoint(QgsPoint(7.8, 47.5))) feature.setAttributes(['some name', 0.0]) pr.addFeatures([feature]) # ... add layer to registry and canvas
The point shows up nicely but in the wrong location. How can I get qgis to interpret my coordinates in lon/lat?