[Qgis-developer] should I use qgsVectorLayer

Tim Sutton lists at linfiniti.com
Fri Aug 5 06:28:22 EDT 2011


Hi Jens

On Fri, Aug 5, 2011 at 11:44 AM, Jens Schwarz <jens_schwarz at gmx.de> wrote:
> Hi All,
>
> I'm developing a little plugin (the first & python-newbie...), which parses
> xml and creates a shapefile. The way it work is similar to the
> "openAdressesConverter" (but using etree, not sax) - there's a little dialog
> asking for the xml-inputpath and the shape-output path. Then click "ok" and
> it creates 2  shapefiles yet. It's just working, but the code needs a big
> refactoring, but in this moment that's a minor matter (not a minor matter at
> all, I know ;)
>
> The things I want to change:
> 1. There are points and lines in the xml - till now, my code creates for
> every layer a single shape file - is it possible, to save those layers (1x
> pointlayer(or maybe 2x), 1x LineString layer) directly in one shapefile?
> I tried qgsVectorLayer like written in the QGIS1.6-tutorial, but I don't
> know how to modify it, because I don't need to use mapCanvas, or
> missunderstood the Class Reference. found some small other samples by
> google, but didn't help.
>
> 2. Is there a method for setting the color of line-Layer? the default color
> for the lines should be red at all.
>
> 3. the (vector)layer should be added in qgis after creating automaticly, so
> you don't have to do it afterwards. Does it work with a simple "def
> addLayer" in the end of the code, or is there a better way to to it (maybe i
> had a mistake in the code, I tried it with a function using open(path))?
>
> If you have an Idea or if I understood anything wrong , please let me know -
> I didn't found answers by searching here, if there's a topic about this,
> please give a link.
>

Most of your questions are answered in the QGIS Python Cookbook. I
would suggest to first read there and then come back to this list if
you have specific queries.

http://www.qgis.org/pyqgis-cookbook/
http://www.qgis.org/pyqgis-cookbook/vector.html#appearance-symbology-of-vector-layers

Good luck!

regards

Tim

> thanks,
> Jens
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list