[Qgis-developer] Adding delimited text file as layer...
Martin Dobias
wonder.sk at gmail.com
Mon Oct 2 05:51:17 EDT 2006
Hi,
the usage should be the same, you just need to load the layer with
other provider and with different URI. Here's how it's done in
delimited text plugin:
QString uri = QString("%1?delimiter=%2&xField=%3&yField=%4")
.arg(filePath)
.arg(delimiter)
.arg(xField)
.arg(yField);
// use "delimitedtext" provider instead of "ogr"
QgsVectorLayer* layer = new QgsVectorLayer(uri, name, "delimitedtext");
Where:
- filePath = complete path to the file
- delimiter = delimiter of the fields
- xField = name of the column with x values
- yField = name of the column with y values
- name = base name of the file (e.g. for path "/tmp/test.txt" it's "test")
I haven't tried that, it's just what I've looked up in the code (take
look at the plugin / provider to find out more).
Martin
On 10/2/06, Schalk Snyman <snymans at wbs.co.za> wrote:
> Hello,
>
> I have written a program to approximate the location of GSM cellphone
> users. At this moment all I really need QGIS for is to display the
> approximated points as well as the GPS points on a map (added as
> shapefile layer) - which pop-up after the calculations.
>
> I would like to use a comma-delimited text file X,Y to add the points as
> a layer. (It's OK if the points are in separate text files)
> I thought this would be relatively easy as this is already done rather
> easily in the QGIS 0.8 gui. However I struggle to keep my head together
> with all the gui slots and Qtishness (I'm new to Qt as well).
>
> I'm using Tim Sutton's "Tutorial 2: Using MapTools with the QGIS Canvas
> API" as a base point. How can I extend this code (with simple includes
> and of course on the same map canvas) to add a points layer from a
> delimited text file?
>
> Best Regards to fellow Developers!
>
> Schalk
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.qgis.org
> http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-developer
>
More information about the Qgis-developer
mailing list