2

I have a series of data, minutes and seconds that are associated with latitude and longitude. I would like to calculate the total distance within each minute, getting a value for each minute.

Now I use:

length(
    transform(
        make_line(
            geometry(get_feature_by_id(@layer, $id)),
            geometry(get_feature_by_id(@layer, $id+1))
            ),
        'EPSG:4326',
        'EPSG:23033'
        )
    )

Which, however, gives me the measure of each point. Does anyone know how to do?

enter image description here

I don't know why but when i try

aggregate(
    @layer,
    'sum',
    length(
        transform(
            make_line(
                geometry(get_feature_by_id(@layer, $id)),
                geometry(get_feature_by_id(@layer, $id+1))
                ),
            'EPSG:4326,
            'EPSG:23033'
            )
        )
    )

QGIS crashes

1
  • 1
    You forgot the simple quote ' at the end of 'EPSG:4326, that's why your syntax is not correct. Correct it and report back if it works like this.
    – Babel
    Commented Apr 1, 2021 at 12:44

1 Answer 1

0

Simply add aggregate( @layer, 'sum', [your expression] ) and replace [your expression] with the expression you provided.

So the whole expression will look like, where apart from the first three and the last line, it is the expression you first provided (be sure the syntax is correct, include all single quotes '):

aggregate( 
    @layer, 
    'sum', 
    length (
        transform (
            make_line (
                geometry ( 
                    get_feature_by_id ( 
                        @layer, 
                        $id 
                    )
                ), 
                geometry ( 
                    get_feature_by_id ( 
                        @layer, 
                        $id+1 
                    )
                )
            ),
            'EPSG:4326', 
            'EPSG:23033'
        )
    )
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.