Cross section river profiles
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
-
- Posts: 8
- Joined: Thu Nov 30, 2017 1:32 pm
Cross section river profiles
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: 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?
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: 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.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Cross section river profiles
welcome to the forum,
can you send me your data as pm for debugging the geodat import?
can you send me your data as pm for debugging the geodat import?
-
- Veteran
- Posts: 3158
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: Cross section river profiles
quick and dirty...
the area of the riverbed is approx 43 m^2.
Thomas
the area of the riverbed is approx 43 m^2.
Thomas
-
- Posts: 8
- Joined: Thu Nov 30, 2017 1:32 pm
Re: Cross section river profiles
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?
But do you also know how to "draw" such profile by myself from my data in FreeCAD?
-
- Veteran
- Posts: 3158
- Joined: Sat May 20, 2017 12:06 pm
- Location: Germany
Re: Cross section river profiles
Sorry, no. As I said above: quick and dirty...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?
Re: Cross section river profiles
It certainly can be done, there will be several ways.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?
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.
I think you mean Draft WB Wire. The problem withz will be your working plane, make sure snap to working plane is off.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?
-
- Posts: 8
- Joined: Thu Nov 30, 2017 1:32 pm
Re: Cross section river profiles
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
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.
Re: Cross section river profiles
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
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)
Last edited by chakkree on Thu Jan 04, 2018 2:42 am, edited 1 time in total.
-
- Posts: 8
- Joined: Thu Nov 30, 2017 1:32 pm
Re: Cross section river profiles
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:
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.
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
PS: I've uploaded a new CSV, because there were wrong values.
- microelly2
- Veteran
- Posts: 4688
- Joined: Tue Nov 12, 2013 4:06 pm
- Contact:
Re: Cross section river profiles
Add the lineCanisLupus 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
Code: Select all
import Draft