0

In qgis 3, postgis, no DEM and zero python knowledge. I've got linestring 3d but Z coordinates is empty, Z-values are stored in table. Z1 for the first node, Z2 for the last node. I found a lot of ways to extract Z to populate the table but never opposite. I try "set Z value" processing, but I can't assign value Z1 to first point and Z2 to last point. I turn around with start_point, end_point,st_z, maybe st_makeline and others but I can't do it.

1

In case your lines are two vertice segments, this simply translates into

UPDATE <table>
  SET geom = ST_SetSRID(
               ST_MakeLine(
                 ST_MakePoint(
                   ST_X(ST_StartPoint(geom)),
                   ST_Y(ST_StartPoint(geom)),
                   "Z1":: FLOAT
                 ),
                 ST_MakePoint(
                   ST_X(ST_EndPoint(geom)),
                   ST_Y(ST_EndPoint(geom)),
                   "Z2":: FLOAT
                 )
               ),
               <SRID>
             )
;

Verbosely written for reference.

In case your LineStrings are polylines (with >2 vertices), this is a lot more involved.

| improve this answer | |
  • Thk. Unfortunately, I've got polylines. And I wish I didn't have to redraw. – pasqal Apr 19 at 14:26
  • I try to compile your response with gis.stackexchange.com/questions/299346/… but I fly... – pasqal Apr 19 at 15:34
  • @pasqal that's not the way to go. You want to interpolate height based on the fraction of linelength at which every point of your lines resides, over the slope of the line between start and end points. I have been to lazy to include that in my answer... – geozelot Apr 19 at 21:17
  • ok, no problem ;-) I thinking about creating pointz layers with my linestring to re-introduce values after. – pasqal Apr 21 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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