Start by joining both files using a common field (right click property/joins).

This could give you a file that looks like this:

fid,x1,y1,x2,y2
1,0,0,1,1
2,10,10,100,100
...

Save this file as geopackage (line).  This way, you can modify it.

x1,y1 are from the first file and x2,y2 are from the second file. These coordinates can be generated by creating a new field and updating it with $x or $y functions in the field calculator.

Then, using the field calculator, select "modify and existing field" and select <geometry>.  Update this field using the following line.

geom_from_wkt('LINESTRING(' ||  "x1"  || ' ' ||  "y1"  || ',' || "x2"  || ' ' ||  "y2"  || ')')

This will create the lines.

Nicolas

On 2020-11-14 7:53 a.m., L.W. wrote:

I tried a lot ...

I have a point-layer, I put this code in symbol -> single symbol -> geometrygenerator

What is wrong?


geom_to_wkt
(
    make_line
    (
        make_point
        (
            5826542.703128459,
            797907.3304607988
        ),
        make_point
        (
            5827473.536854242,
            796987.0074038045
        ),
        make_point
        (
            5827167.893279332,
            795128.2317764781
        ),
        make_point
        (
            5826835.7783904355,
            793227.8583700341
        )
    )
)

Am 13.11.2020 um 15:24 schrieb Andreas Neumann:

Hi Nicolas,

Yes - but that doesn't magically turn a "non geometry" table into a "geometry table" - as far as I know. So you probably need to create a "Virtual Layer" and create the geometry similar to what you propose.

Andreas

Am 13.11.20 um 15:22 schrieb Nicolas Cadieux:
Hi,
You can create a geometry from WKT if you have x and y fields using and expression in the field calculator.
|geom_from_wkt('POINT('||"x"||' '||"y"||')')|

https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry

Nicolas Cadieux

Le 13 nov. 2020 à 09:07, Andreas Neumann <a.neum...@carto.net> a écrit :



Hi

Neither GeometryGenerators nor Vector Field Markers work on tables without geometry, unfortunately. You didn't inform us, that you don't have geometry in your table.

You can, however, create a "Virtual Layer" and write some SQL to create a geometry from your attributes: menu "Layer" --> "Create Layer" --> "New Virtual Layer" - where you can use your existing tables and create a new geometry column with SQL. See https://docs.qgis.org/testing/en/docs/user_manual/managing_data_source/create_layers.html#creating-virtual-layers

Or, if your table is a CSV file, then you can assign attribute columns to a point geometry and then just hide the point rendering if you don't need it.

This is an unfortunate limitation of QGIS, that there is no "easy" way to add a geometry column to table that doesn't have geometry (or if it is possible, then I don't know it).

Hope this helps you,

Andreas

Am 13.11.20 um 14:52 schrieb L.W.:

Does it works on Layers with no geometry?

My layers do not have a geometry.


Am 13.11.2020 um 11:56 schrieb Andreas Neumann:

Yes, you need point data to start from, but then vectors can bei/are generated from the attributes you mentioned.

Andreas

Am 13.11.20 um 11:47 schrieb L.W.:

from the docs ...

****It can only be used to render point data****


        12.2.2.2.6.The Vector Field Marker
        
<https://docs.qgis.org/3.10/en/docs/user_manual/style_library/symbol_selector.html?#id15>

The vector field marker is used to display vector field data such as earth deformation, tidal flows, and the like. It displays the vectors as lines (preferably arrows) that are scaled and oriented according to selected attributes of data points. ****It can only be used to render point data****; line and polygon layers are not drawn by this symbology.

The vector field is defined by attributes in the data, which can represent the field either by:

 *

    *cartesian*components (|x|and|y|components of the field)

 *

    or*polar*coordinates: in this case, attributes
    define|Length|and|Angle|. The angle may be measured either
    clockwise from north, or Counterclockwise from east, and may
    be either in degrees or radians.

 *

    or as*height only*data, which displays a vertical arrow
    scaled using an attribute of the data. This is appropriate
    for displaying the vertical component of deformation, for
    example.

The magnitude of field


Am 13.11.2020 um 11:34 schrieb Andreas Neumann:
Or even easier: use the "Vector Field Marker":

https://docs.qgis.org/3.10/en/docs/user_manual/style_library/symbol_selector.html?#the-vector-field-marker

Am 13.11.20 um 11:33 schrieb Andreas Neumann:
Hi,

Yes - you can use Geometry Generators for that. Use the make_point() and make_line() expressions for that.

See https://docs.qgis.org/3.10/en/docs/user_manual/style_library/symbol_selector.html?highlight=geometry%20generator#the-geometry-generator

Greetings,
Andreas

Am 13.11.20 um 11:26 schrieb L.W.:
Hi,

is it possible to draw automatically a line between two points defined
by 4 fields (x1,y1 - x2,y2) in an attributetable?

but I do not want to add a line-layer based on this table nor want to
draw the line by hand.

thanks

_______________________________________________
Qgis-user mailing list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@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 list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to