I'm trying to load some points through a vectorlayer on my QMainWindow, part of my pyqgis application. The code is:
uri = 'file:///C:/Users/.../data/Targets_com.csv?delimiter=,&crs=epsg:4326&xField=x&yField=y' # uri = 'file:///C:/Users/.../data/Targets_wkt.csv?delimiter=,&crs=epsg:4326'#&wktField=wkt' # Loading the layer and check it: self.target_layer = QgsVectorLayer(uri, 'Targets' , 'delimitedtext') if self.target_layer.isValid(): QgsMapLayerRegistry.instance().addMapLayer(self.target_layer) print('Layer OKKK') else: print('Layer Fail') self.target_layer.updateExtents()
When I run my application with that, I get "Layer Fail", so for sure there is something wrong in my "uri" definition, isn't it?
If I change uri like:
uri = 'file:///C:/Users/.../data/Targets_com.csv?delimiter=,&crs=epsg:4326'
that is, cutting the geometry definition (on both cases: (x,y) and wkt), I get the "Layer OKKK", but I can't see my points on the map.
I think the .csv files are well written, cause I can load them on QGIS. Anyway, this are my files.csv (and I tried with one more using ";" like delimiter):
I have read all the posts I found about csv files and syntax with qgis, but I don't know how to solve this, anyone have any idea? i'm using the OSGeo4W package (QGIS 2.16, its own python interpreter, PyQt4,...) and using eclipse-PyDev for development.