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
cebda2a9
Commit
cebda2a9
authored
1 year ago
by
Sara Savanovic Djordjevic
Browse files
Options
Downloads
Patches
Plain Diff
update: attempt to get only intersetcing lines, plotting error
parent
967a8662
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
Clhp map
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/map/__pycache__/get_relation.cpython-311.pyc
+0
-0
0 additions, 0 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
server/map/get_relation.py
+20
-3
20 additions, 3 deletions
server/map/get_relation.py
with
20 additions
and
3 deletions
server/map/__pycache__/get_relation.cpython-311.pyc
+
0
−
0
View file @
cebda2a9
No preview for this file type
This diff is collapsed.
Click to expand it.
server/map/get_relation.py
+
20
−
3
View file @
cebda2a9
...
...
@@ -2,9 +2,7 @@ import geopandas as gpd
from
shapely.geometry
import
Polygon
,
LineString
from
shapely.ops
import
linemerge
,
unary_union
,
polygonize
import
matplotlib.pyplot
as
plt
import
matplotlib.ticker
as
ticker
import
random
import
math
import
numpy
as
np
polygon_min_x
=
None
# The left most point of the entire polygon
...
...
@@ -26,7 +24,9 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water
lines
.
append
(
polygon
.
boundary
)
lines
=
unary_union
(
lines
)
lines
=
linemerge
(
lines
)
divided_map
.
extend
(
list
(
polygonize
(
lines
)))
lines
=
(
list
(
polygonize
(
lines
)))
divided_map
=
combine_gird_with_poly
(
polygon
,
lines
)
tiles
=
gpd
.
GeoDataFrame
(
geometry
=
divided_map
)
...
...
@@ -95,3 +95,20 @@ def create_grid(poly: Polygon, cell_size):
x
+=
cell_size
return
grid_lines
def
combine_gird_with_poly
(
polygon
,
grid
):
# Create an empty list to store tiles intersecting the polygon
intersecting_tiles
=
[]
# Iterate through each grid line
for
line
in
grid
:
# Check if the line intersects with the polygon
if
line
.
intersects
(
polygon
):
# If the line intersects, find the intersection points
intersection
=
line
.
intersection
(
polygon
)
# Add each line to the list
intersecting_tiles
.
append
(
intersection
)
return
intersecting_tiles
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