Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PROG2900
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sara Savanovic Djordjevic
PROG2900
Commits
aaecdfe7
Commit
aaecdfe7
authored
1 year ago
by
Hoa Ben The Nguyen
Browse files
Options
Downloads
Patches
Plain Diff
change: a little more organized
parent
0cd1b498
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/data_processing/area_processing.py
+55
-0
55 additions, 0 deletions
server/data_processing/area_processing.py
server/data_processing/process_lidar_data.py
+3
-56
3 additions, 56 deletions
server/data_processing/process_lidar_data.py
with
58 additions
and
56 deletions
server/data_processing/area_processing.py
+
55
−
0
View file @
aaecdfe7
import
math
from
itertools
import
groupby
from
math
import
pi
,
cos
from
math
import
pi
,
cos
EARTH
=
6378.137
# Radius of the earth in kilometer
EARTH
=
6378.137
# Radius of the earth in kilometer
METER
=
(
1
/
((
2
*
pi
/
360
)
*
EARTH
))
/
1000
# 1 meter in degree
METER
=
(
1
/
((
2
*
pi
/
360
)
*
EARTH
))
/
1000
# 1 meter in degree
# check if lidar points is within range of the area selected
def
inArea
(
position
,
areaRange
):
y
,
x
,
_
=
position
# position to be checked
if
(
abs
(
areaRange
[
0
][
0
])
>
x
>
abs
(
areaRange
[
1
][
0
]))
and
(
abs
(
areaRange
[
0
][
1
])
>
abs
(
y
)
>
abs
(
areaRange
[
1
][
1
])):
return
True
else
:
return
False
# find distance between two points
def
distance
(
point1
,
point2
):
y1
,
x1
=
point1
y2
,
x2
=
point2
return
math
.
sqrt
(
abs
(
y2
-
y1
)
**
2
+
abs
(
x2
-
x1
)
**
2
)
# find the closest point in json list
def
closest_points
(
point
,
list
,
coords_taken
):
closest_point_found
=
None
closest_dist
=
float
(
'
inf
'
)
for
current_point
in
list
:
dist
=
distance
(
point
,
current_point
[
'
properties
'
][
'
sub_div_center
'
][
0
])
if
dist
<
closest_dist
and
current_point
not
in
coords_taken
:
closest_dist
=
dist
closest_point_found
=
current_point
return
closest_point_found
# Calculation of height in an area from las files
def
find_height
(
points
):
print
(
points
,
"
5
"
)
height_differences
=
[]
# final container for height data
# sort the points
sorted_coords
=
sorted
(
points
,
key
=
lambda
coord
:
(
coord
[
0
],
coord
[
1
]))
# group the sorted points that has the same xy- coordinates together
groupCoords
=
[
list
(
group
)
for
key
,
group
in
groupby
(
sorted_coords
,
key
=
lambda
coord
:
(
coord
[
0
],
coord
[
1
]))]
# loop through the groups to find the difference in height
for
group
in
groupCoords
:
if
len
(
group
)
<
2
or
group
[
0
]
==
group
[
1
]:
continue
# jump over iteration if there is only one coordinate or lidar registered the same point twice
# find max and min height
min_height
=
min
(
coords
[
2
]
for
coords
in
group
)
max_height
=
max
(
coords
[
2
]
for
coords
in
group
)
# difference between them
difference
=
max_height
-
min_height
height_differences
.
append
(
difference
)
# list of thickness in an area
return
height_differences
def
calculate_corners
(
lat
,
lng
,
area_offset
):
def
calculate_corners
(
lat
,
lng
,
area_offset
):
"""
Calculate corners of polygon based on a center coordinate
"""
Calculate corners of polygon based on a center coordinate
...
...
This diff is collapsed.
Click to expand it.
server/data_processing/process_lidar_data.py
+
3
−
56
View file @
aaecdfe7
...
@@ -3,11 +3,10 @@ import laspy
...
@@ -3,11 +3,10 @@ import laspy
import
json
import
json
import
math
import
math
import
utm
# src: https://github.com/Turbo87/utm
import
utm
# src: https://github.com/Turbo87/utm
from
itertools
import
groupby
from
server.data_processing.area_processing
import
(
calculate_corners
,
define_gridareas
,
inArea
,
from
server.data_processing.area_processing
import
calculate_corners
,
define_gridareas
find_height
,
closest_points
)
# hard coded files for test datas
# hard coded files for test data
lazData_path
=
[
"
server/example_lidar_data/ot_N_000005_1.laz
"
,
"
server/example_lidar_data/ot_N_000033_1.laz
"
]
lazData_path
=
[
"
server/example_lidar_data/ot_N_000005_1.laz
"
,
"
server/example_lidar_data/ot_N_000033_1.laz
"
]
# Info about data
# Info about data
...
@@ -30,58 +29,6 @@ def about_laz_file():
...
@@ -30,58 +29,6 @@ def about_laz_file():
return
[
las
.
header
.
version
,
las
.
header
.
point_count
,
las
.
header
.
scale
,
las
.
header
.
offset
]
return
[
las
.
header
.
version
,
las
.
header
.
point_count
,
las
.
header
.
scale
,
las
.
header
.
offset
]
# check if lidar points is within range of the area selected
def
inArea
(
position
,
areaRange
):
y
,
x
,
_
=
position
# position to be checked
if
(
abs
(
areaRange
[
0
][
0
])
>
x
>
abs
(
areaRange
[
1
][
0
]))
and
(
abs
(
areaRange
[
0
][
1
])
>
abs
(
y
)
>
abs
(
areaRange
[
1
][
1
])):
return
True
else
:
return
False
# find distance between two points
def
distance
(
point1
,
point2
):
y1
,
x1
=
point1
y2
,
x2
=
point2
return
math
.
sqrt
(
abs
(
y2
-
y1
)
**
2
+
abs
(
x2
-
x1
)
**
2
)
# find the closest point in json list
def
closest_points
(
point
,
list
,
coords_taken
):
closest_point_found
=
None
closest_dist
=
float
(
'
inf
'
)
for
current_point
in
list
:
dist
=
distance
(
point
,
current_point
[
'
properties
'
][
'
sub_div_center
'
][
0
])
if
dist
<
closest_dist
and
current_point
not
in
coords_taken
:
closest_dist
=
dist
closest_point_found
=
current_point
return
closest_point_found
# Calculation of height in an area from las files
def
find_height
(
points
):
print
(
points
,
"
5
"
)
height_differences
=
[]
# final container for height data
# sort the points
sorted_coords
=
sorted
(
points
,
key
=
lambda
coord
:
(
coord
[
0
],
coord
[
1
]))
# group the sorted points that has the same xy- coordinates together
groupCoords
=
[
list
(
group
)
for
key
,
group
in
groupby
(
sorted_coords
,
key
=
lambda
coord
:
(
coord
[
0
],
coord
[
1
]))]
# loop through the groups to find the difference in height
for
group
in
groupCoords
:
if
len
(
group
)
<
2
or
group
[
0
]
==
group
[
1
]:
continue
# jump over iteration if there is only one coordinate or lidar registered the same point twice
# find max and min height
min_height
=
min
(
coords
[
2
]
for
coords
in
group
)
max_height
=
max
(
coords
[
2
]
for
coords
in
group
)
# difference between them
difference
=
max_height
-
min_height
height_differences
.
append
(
difference
)
# list of thickness in an area
return
height_differences
# find the height of an area based on the coordinates of it's center
# find the height of an area based on the coordinates of it's center
# and it's affiliations (subId and groupId) (soon to be implemented
# and it's affiliations (subId and groupId) (soon to be implemented
def
calculate_area_data
(
center
,
body_of_water
):
def
calculate_area_data
(
center
,
body_of_water
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment