Cross section river profiles

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
CanisLupus
Posts: 8
Joined: Thu Nov 30, 2017 1:32 pm

Cross section river profiles

Post by CanisLupus »

I'm absolutely new in FreeCAD. Formerly I only used GIS software and no CAD, but I'm very experienced in GIS.

So my problem is I have a mapping job for meassuring cross sections of a river bed. The customer wants somthing like this from me for each cross section profile:
example_profile.jpg
example_profile.jpg (55.58 KiB) Viewed 2949 times
What I've meassured were the XYZ-coordinates of each point in ETRS89/UTM Zone 32N. The data which I gathered with the device is stored in a CSV file with the headers: name,x,y,z. So what I've tried first is to import the CSV in QGIS and saved it as a SHP and also as a DXF and GPX with included z coordinates. I've successfully imported the points from the DXF in FreeCAD. They are displayed in the right realation to each other and also with their respective Z values. Unfortunately the points were not imported in the right scale. Were a point pair in QGIS has a distance of 1.4 m the distance in FreeCAD has around 0.34 m. How I can configure the right scale?
I also tried to import the data with the Geo Data workbench CSV import tool. I get the error "Index error: list index out of range". The same error appears with the GPX import tool. Do you know how to fix that error?
What I also tried is to connect the wrong scaled points with multiple-point DrawWires and endpoint snapping. The lines snaps on the points, but not on their z value. What is wrong?

So what idea do you have to get such cross section profiles from my spatial measuring data shown above in FreeCAD? Or is it impossible?
Last edited by CanisLupus on Tue Dec 12, 2017 2:29 pm, edited 2 times in total.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Cross section river profiles

Post by microelly2 »

welcome to the forum,

can you send me your data as pm for debugging the geodat import?
thschrader
Veteran
Posts: 3157
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Cross section river profiles

Post by thschrader »

quick and dirty...
the area of the riverbed is approx 43 m^2.
Thomas
riverbed.FCStd
(57.15 KiB) Downloaded 65 times
riverbed.JPG
riverbed.JPG (103.01 KiB) Viewed 3284 times
CanisLupus
Posts: 8
Joined: Thu Nov 30, 2017 1:32 pm

Re: Cross section river profiles

Post by CanisLupus »

thschrader, thank you for your reply. It's a nice feature.
But do you also know how to "draw" such profile by myself from my data in FreeCAD?
thschrader
Veteran
Posts: 3157
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Cross section river profiles

Post by thschrader »

CanisLupus wrote: Tue Dec 05, 2017 7:08 pm thschrader, thank you for your reply. It's a nice feature.
But do you also know how to "draw" such profile by myself from my data in FreeCAD?
Sorry, no. As I said above: quick and dirty... :)
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Cross section river profiles

Post by jmaustpc »

CanisLupus wrote: Tue Dec 05, 2017 7:08 pm thschrader, thank you for your reply. It's a nice feature.
But do you also know how to "draw" such profile by myself from my data in FreeCAD?
It certainly can be done, there will be several ways.

Can you please post your version data in the manner explain in the forum rules link above. Also please post your CVS file or if privacy is an issue perhaps just post a subset of the data, perhaps for example just one cross section.

I suspect the name column is causing import errors and possibly the data will import if it is just a list of xyz. It could also be imported as a point cloud in points wb. Then all the points would be one item ...a point cloud rather than a series of individual points.
CanisLupus wrote: Thu Nov 30, 2017 2:27 pm What I also tried is to connect the wrong scaled points with multiple-point DrawWires and endpoint snapping. The lines snaps on the points, but not on their z value. What is wrong?
I think you mean Draft WB Wire. The problem withz will be your working plane, make sure snap to working plane is off.
CanisLupus
Posts: 8
Joined: Thu Nov 30, 2017 1:32 pm

Re: Cross section river profiles

Post by CanisLupus »

Version Info:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6712 (Git)
Build type: Release
Branch: releases/FreeCAD-0-16
Hash: da2d364457257a7a8c6fb2137cea12c45becd71a
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

Attached some example data as CSV.
The naming of each dataset:
– first number digit means the cross section number
– q means "querprofil" in german = cross section
- last number digits mean serial numbers for each measured point in its respective cross section
Attachments
example_data.csv
(2.03 KiB) Downloaded 78 times
Last edited by CanisLupus on Tue Dec 12, 2017 10:16 am, edited 1 time in total.
User avatar
chakkree
Posts: 327
Joined: Tue Jun 30, 2015 12:58 am
Location: Bangkok Thailand

Re: Cross section river profiles

Post by chakkree »

I'm trying import data and draw with python.
The first data, named '1qp01', x value has some problem. It's very far from x's data group.

{edit} fixed import Draft

Code: Select all

import Arch
import Draft 
import csv

from FreeCAD import Vector

path = 'D:\\Data\\RiverCrossSection\\'
fName = path+'example_data.csv'
CrossSection = {}

with open(fName, 'rb') as csvfile:
    data = csv.reader(csvfile, delimiter=',')
    count = 1
    for row in data:
        #Msg(row); Msg('\n')
        if count>1:
            name = row[0]
            str1 = name.split('q')
            id = str1[0]
            pointName = str1[1]
            x  = row[1]
            y  = row[2]
            z  = row[3]
            pointData = (x,y,z)
            if CrossSection.has_key(id):                
                #CrossSection[id].append( pointData )
                CrossSection[id][pointName]= pointData 
            else:
                pointData = {pointName:pointData}
                CrossSection[id] = pointData
        count+=1 

Msg(CrossSection); Msg('\n')

minX = 10000000
minY = 10000000
minZ = 10000000

for iSection in CrossSection:
    #Msg(iSection); Msg('\n\n')
    #Msg(CrossSection[iSection]); Msg('\n\n')
    for iPoint in CrossSection[iSection]:
        #Msg(CrossSection[iSection][iPoint]); Msg('\n')
        x = float( CrossSection[iSection][iPoint][0] )
        y = float( CrossSection[iSection][iPoint][1] )
        z = float( CrossSection[iSection][iPoint][2] )
        if x<minX: minX = x
        if y<minY: minY = y
        if z<minZ: minZ = z
    #Msg('\n')

Msg('%g , %g , %g\n'%(minX, minY,minZ) )

datumElev = minZ - 1.0
doc = FreeCAD.ActiveDocument

for iSection in CrossSection:
    doc.addObject("App::DocumentObjectGroup","Section%s"%iSection)


for iSection in CrossSection:
    #for i in range(0,len(CrossSection[iSection])+1):
    group = doc.getObjectsByLabel("Section%s"%iSection)[0]
    for iPoint in CrossSection[iSection]:
        Pnt2 = Vector( CrossSection[iSection][iPoint] )
        Pnt2[0]-=minX; Pnt2[1]-=minY; Pnt2[2]-= minZ

        Pnt1 =  Vector( CrossSection[iSection][iPoint] )
        Pnt1[0]-=minX; Pnt1[1]-=minY; Pnt1[2]-= minZ
        Pnt1[2] = -2.
        #Msg(Pnt1);  Msg(Pnt2); Msg('\n')
        points = [Pnt1*1000 , Pnt2*1000]
        line = Draft.makeWire(points)
        line.Label = "%sq%s"%(iSection, iPoint)
        group.addObject(line)

for iSection in CrossSection:
    group = doc.getObjectsByLabel("Section%s"%iSection)[0]
    for i in range(1,len(CrossSection[iSection])):
        name1 = 'p%02d'%i
        name2 = 'p%02d'%(i+1)
        Pnt1 = Vector( CrossSection[iSection][name1] )
        Pnt1[0]-=minX; Pnt1[1]-=minY; Pnt1[2]-= minZ
        Pnt2 = Vector( CrossSection[iSection][name2] )
        Pnt2[0]-=minX; Pnt2[1]-=minY; Pnt2[2]-= minZ
        points = [Pnt1*1000 , Pnt2*1000]
        line = Draft.makeWire(points)
        line.Label = "%s_%s"%(name1, name2)
        group.addObject(line)

RiverCrossSection.png
RiverCrossSection.png (290.52 KiB) Viewed 3040 times
Last edited by chakkree on Thu Jan 04, 2018 2:42 am, edited 1 time in total.
CanisLupus
Posts: 8
Joined: Thu Nov 30, 2017 1:32 pm

Re: Cross section river profiles

Post by CanisLupus »

Hello chakkree,
many thank you for your effort!
I've tested your code, it worked except the last two for-loops. I will get the following errors:

Code: Select all

>>> for iSection in CrossSection:
...     #for i in range(0,len(CrossSection[iSection])+1):
...     group = doc.getObjectsByLabel("Section%s"%iSection)[0]
...     for iPoint in CrossSection[iSection]:
...         Pnt2 = Vector( CrossSection[iSection][iPoint] )
...         Pnt2[0]-=minX; Pnt2[1]-=minY; Pnt2[2]-= minZ
... 
...         Pnt1 =  Vector( CrossSection[iSection][iPoint] )
...         Pnt1[0]-=minX; Pnt1[1]-=minY; Pnt1[2]-= minZ
...         Pnt1[2] = -2.
...         #Msg(Pnt1);  Msg(Pnt2); Msg('\n')
...         points = [Pnt1*1000 , Pnt2*1000]
...         line = Draft.makeWire(points)
...         line.Label = "%sq%s"%(iSection, iPoint)
...         group.addObject(line)
... 
Traceback (most recent call last):
  File "<input>", line 13, in <module>
NameError: name 'Draft' is not defined
>>> for iSection in CrossSection:
...     group = doc.getObjectsByLabel("Section%s"%iSection)[0]
...     for i in range(1,len(CrossSection[iSection])):
...         name1 = 'p%02d'%i
...         name2 = 'p%02d'%(i+1)
...         Pnt1 = Vector( CrossSection[iSection][name1] )
...         Pnt1[0]-=minX; Pnt1[1]-=minY; Pnt1[2]-= minZ
...         Pnt2 = Vector( CrossSection[iSection][name2] )
...         Pnt2[0]-=minX; Pnt2[1]-=minY; Pnt2[2]-= minZ
...         points = [Pnt1*1000 , Pnt2*1000]
...         line = Draft.makeWire(points)
...         line.Label = "%s_%s"%(name1, name2)
...         group.addObject(line)
... 
Traceback (most recent call last):
  File "<input>", line 11, in <module>
NameError: name 'Draft' is not defined
Do I need some more libaries? Or I have to change a name?

PS: I've uploaded a new CSV, because there were wrong values.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Cross section river profiles

Post by microelly2 »

CanisLupus wrote: Tue Dec 12, 2017 10:22 am I will get the following errors:
Traceback (most recent call last):
File "<input>", line 13, in <module>
NameError: name 'Draft' is not defined
Add the line

Code: Select all

import Draft 
at the bin of your script
Post Reply