[Qgis-user] importing data to map

Marcin prokes95 at interia.pl
Sat Mar 21 15:38:20 PDT 2020


Hi folks,QGIS 3.10I would like to create polygons (see 4 corners everyone) with Python form .csv like that:LP	CORNER	Y	X1	1	51.558868	21.6969851	2	51.596337	21.7455891	3	51.603166	21.7276871	4	51.565424	21.6824162	1	51.590928	21.7604422	2	51.553125	21.7098472	3	51.559536	21.69592	4	51.598023	21.7420783	1	51.548047	21.7243273	2	51.586238	21.7738433	3	51.593172	21.7561853	4	51.554643	21.709932According to QGIS Python Programming Cookbook I know how to load csv file:uri = "D:/PODYPLOM/plikiCSVtoSHPviaPythonpokrycieCSV.csv?"uri += "type=csv&"uri += "xField=X&yField=Y&"uri += "spatialIndex=no&"uri += "subsetIndex=no&"uri += "watchFile=no&"uri += "crs=epsg:4326"layer=QgsVectorLayer(uri,"Tourism Sites","delimitedtext")QgsProject.instance().addMapLayers([layer])and I know how to create polygon layer from points added by finger:vectorLyr = QgsVectorLayer('D:/qgis_data/polygon/polygon.shp', 'Polygon', "ogr")vpr = vectorLyr.dataProvider()points = []points.append(QgsPointXY(-123.26,49.06))points.append(QgsPointXY(-127.19,43.07))points.append(QgsPointXY(-120.70,35.21))points.append(QgsPointXY(-115.89,40.02))points.append(QgsPointXY(-123.26,49.06))poly = QgsGeometry.fromPolygonXY([points])f = QgsFeature()f.setGeometry(poly)vpr.addFeatures([f])vectorLyr.updateExtents()but I can't load points from csv to line: points.append(QgsPointXY())Anybody can help me how to do this ?Cheers, Marcin PietruszewskiOd: "Didier Peeters" <dpeeter1 at ulb.ac.be>Do: "qgis-user" <qgis-user at lists.osgeo.org>; Wysłane: 10:26 Sobota 2020-03-21Temat: Re: [Qgis-user] importing data to mapHi,I don't know about your data or what you call a "function" here, but yes you need to have it loaded in QGis as a layer (with or without geometry).  To do so and supposing you have a .xls or .xlsx file you can install the 'Spreadsheet Layers' plugin, which  adds a "Add spreadsheet layer" entry in "Layer" / "Add new Layer" menu and a corresponding button in the "Layers" toolbar.   Alternatively you could maybe convert your data into a .csv file and load it as well.   Once your file is loaded you should be able to create the relation.  DidierLe 21 mars 2020 à 08:49, Boaz Bar Ilan <boazprosie at gmail.com> a écrit :hi thanks I need  to present all the functions as one layer so how can this help me?‫בתאריך יום ו׳, 20 במרץ 2020 ב-15:39 מאת ‪Didier Peeters‬‏ <‪dpeeter1 at ulb.ac.be‬‏>:‬Hi,
You need to use a Relation, in the project properties (Menu: Project > Properties > Relations).  
See these videos to understand how it works :https://youtu.be/MeBnasFHGGQhttps://youtu.be/OowgI1b2ihw
Cheers,
Didier
> Le 20 mars 2020 à 12:33, Boaz Bar Ilan <boazprosie at gmail.com> a écrit :
> 
> hi there
>  I got data xcls which describes functions in relation to parcells
> im trying to import this spreadsheet to a map of parcells  and what happen of course that if there are 2 functions in the same parcel - it shows only one!
> how can I show  2 functions or more related to the same parcel  ?
> 
> I can use the add polygon feature but than it should be done manually one by one
> is there different way ?
> thanks
> boaz
> 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing listQgis-user at lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20200321/b390506c/attachment.html>


More information about the Qgis-user mailing list