# Simplifying geometries and calculating non-spatial averages

I'm quite new to using proper spatial tools, and have a simple question that doesn't immediately show up on google.

I have a table that contains multiple rows of empiric data (say, speed of a vehicle) that also has spatial information connected to it. Every speed measure (real number) has a linestring geometry to it.

Many of those Linestrings are touching each other on the end points.

1. visualize all groups of touching lines as separate multilines
2. simplify each of the resulting multilines to reduce the amount of points and consequently data to be displayed (i.e. when we "zoom out", so I need configurable loss of precision)
3. aggregate average speed for every segment in each simplified multiline

Now, I understand that spatial simplification and scalar aggregation probably use different algorithms, but what's the common approach to this?

UPDATE:

Here's some data:

geom                                             |speed
LINESTRING(25.51369 65.01514, 25.51362 65.01521) |21.6324731983004
LINESTRING(25.51362 65.01521, 25.51369 65.01514) |20.7681850053341
LINESTRING(24.95117 60.1898, 24.95112 60.18981)  |15.5648781827192
LINESTRING(24.8263 60.20353, 24.82685 60.2035)   |19.7643783824494
LINESTRING(24.82685 60.2035, 24.8263 60.20353)   |15.2009950253671

I have understood that ST_Union(), ST_LineMerge() and ST_Simplify() can take care of building a joined multiline and reducing its complexity.

Part 3 of the task still stands: how do I calculate average speed values for various parts of the newly created and simplified multiline?

• "aggregate average speed for every segment in each simplified multiline" - so you want the average speed to be different per zoom level? – Jakub Kania Nov 23 '14 at 13:41
• Since simplified geometry would be different, yes, speed would also differ between zoom levels – Dennis Kreminsky Nov 23 '14 at 14:53
• 'zooming' suggests that you are viewing the data via a viewer of some sort; it's not an inherent property that you can calculate. If you have some spatial unit that you can aggregate upwards, perhaps you could use that? Can you post an example of the data illustrating the table structure? – djq Nov 24 '14 at 4:41
• Of course there has to be some zoom-related parameter that would be used in aggregation, not just some "zoom". Let's say every row has exactly two fields: geom and speed, geom is always a linestring, speed is a floating point number. – Dennis Kreminsky Nov 24 '14 at 6:26
• Do you mean average speed for each simplified multilinestring or for each linestring in the multilinestrings? – John Powell Nov 24 '14 at 12:43