Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:27:42+00:00 2026-06-06T19:27:42+00:00

I’m using CartoDB as a PostGIS server for my app. I need to store

  • 0

I’m using CartoDB as a PostGIS server for my app.

I need to store tracks and associate a timestamp for each coordinate pair of track points, in order to make queries like give me the distance traveled between 12AM and 12PM on day X.

In CartoDB I can only create 3 types of Tables: MULTIPOINT, MULTILINESTRING and MULTIPOLYGON. To insert tracks I’m using a MULTILINESTRING table.

My first attemp was to insert the timestamp as the Z index for each point in the MULTILINESTRING, however I always get an ERROR: Geometry has Z dimension but column does not.

How is this achieved in a “normal” PostGIS database and also how can I achieve it in CartoDB PostGIS implementation?

UPDATE 1:

So after jatorre answer I created a JSFiddle example as a practicing exercise.
However I’m getting incoherent results.

In the example above I have two tables with the same two datasets. However one is a MULTILINESTRING table in which each row represents a segment and the other is a MULTIPOINT table in which I store each segment set of coordinates.

Then I query these two tables to get the total distance of segments according to transport mode. I think I got jattore’s idead pretty clearly, however I don’t understand why I get different results for Car and Walk total distance. Any hints?

SOLUTION:

The small diferences in distances were because I needed to sort the points table before grouping the segment.
This is my current query to get the total distance and time traveled according to transport mode:

WITH segments AS 
  (SELECT ST_Makeline(pts.the_geom_webmercator) as the_geom, (MAX(pts.timestamp) - MIN(pts.timestamp)) AS time, paths.transport_mode, paths.cartodb_id AS id
   FROM (SELECT * FROM points ORDER BY track_id, path_id, timestamp ASC) AS pts JOIN paths ON pts.path_id=paths.cartodb_id
   WHERE paths.user_id=1
   GROUP BY id, transport_mode)
SELECT SUM(ST_Length(segments.the_geom)) AS distance, SUM(segments.time), segments.transport_mode
FROM segments
GROUP BY segments.transport_mode
ORDER BY distance
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:27:44+00:00Added an answer on June 6, 2026 at 7:27 pm

    Well, it depends a bit.

    Imagine you have an structure of GPS traces. In this case you will convert those GPS traces into Segments, lines of just two coordinates, and you can have start_time and end_time separated columns.

    Then with that structure you can do a SELECT with a WHERE clause between those dates and summing the ST_Length_Spheroid of the segments.

    If you want to do all in one single query, considering that you have a table with:

    the_geom(point), timestamp, cartodb_id
    

    The you can do something like

    WITH segments AS 
    (SELECT ST_MakeLine(
       the_geom,
       (SELECT the_geom FROM tracks as st WHERE st.cartodb_id = t.cartodb_id+1)
    ) as the_geom
    FROM traces as t WHERE timestamp BETWEEN ...)
    SELECT sum(ST_Length_Spheroid(segments.the_geom)
    

    This is totally our of my head… but i hope you get the idea.

    You dont need to use Z dimension and actually we dont well support that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.