Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the gallery example for plotting lines with LineString/MultiLineString geometry #3711

Merged
merged 25 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3696994
Update gpd lines gallery example
michaelgrund Dec 24, 2024
c6bfba4
update
michaelgrund Dec 24, 2024
8c5bfa8
update name
michaelgrund Dec 25, 2024
db9915b
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 25, 2024
d222759
Apply suggestions from code review
michaelgrund Dec 26, 2024
47dabbc
Apply suggestions from code review
michaelgrund Dec 26, 2024
1dbebb5
remove empty rows
michaelgrund Dec 26, 2024
45c04fa
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 26, 2024
17284c2
update
michaelgrund Dec 26, 2024
e4442a3
update
michaelgrund Dec 26, 2024
23ba61a
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 26, 2024
97aaa81
[format-command] fixes
actions-bot Dec 26, 2024
736e519
add data via geodatasets
michaelgrund Dec 26, 2024
3d9703a
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 26, 2024
b4fa12c
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 26, 2024
76ed9de
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 26, 2024
b3e0e27
Apply suggestions from code review
michaelgrund Dec 26, 2024
2231241
fix typo
michaelgrund Dec 26, 2024
d2dc007
Update linestrings.py
michaelgrund Dec 30, 2024
8087c1c
Apply suggestions from code review
michaelgrund Dec 30, 2024
72d2cc1
Wrap line to 88 chars
michaelgrund Dec 30, 2024
b7fab6d
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund Dec 30, 2024
573309c
rm trailing ws
michaelgrund Dec 30, 2024
ac4b31d
Apply suggestions from code review
seisman Dec 31, 2024
49e9816
Merge branch 'main' into upd-gpd-lines-gallery
seisman Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions examples/gallery/lines/linestrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# ruff: noqa: RUF003
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
"""
Plotting lines with LineString/MultiLineString geometry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it makes more sense to change the title to:

GeoPandas: Plotting lines with LineString/MultiLineString geometry

=====
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved

The :meth:`pygmt.Figure.plot` method allows us to plot geographical data such
as lines which are stored in a :class:`geopandas.GeoDataFrame` object. Use
:func:`geopandas.read_file` to load data from any supported OGR format such as
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:func:`geopandas.read_file` to load data from any supported OGR format such as
:func:`geopandas.read_file` to load data from any supported OGR formats such as

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think format is correct here.

michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
a shapefile (.shp), GeoJSON (.geojson), geopackage (.gpkg), etc. Then, pass the
:class:`geopandas.GeoDataFrame` as an argument to the ``data`` parameter of
:meth:`pygmt.Figure.plot`, and style the geometry using the ``pen`` parameter.
"""

# %%
import geopandas as gpd
import pygmt

# Read shapefile data using geopandas
gpd_lines = gpd.read_file(
"https://www.eea.europa.eu/data-and-maps/data/wise-large-rivers-and-large-lakes/zipped-shapefile-with-wise-large-rivers-vector-line/zipped-shapefile-with-wise-large-rivers-vector-line/at_download/file/" + \
"wise_large_rivers.zip"
)

gpd_lines.crs
# Convert object to EPSG 4326 coordinate system
gpd_lines_new = gpd_lines.to_crs("EPSG:4326")
gpd_lines_new

fig = pygmt.Figure()

fig.coast(
projection="M10c",
region=[-10, 30, 35, 57],
resolution="l",
land="gray95",
shorelines="1/0.1p,gray50",
borders="1/0.1,gray30",
frame=True,
)

# Add rivers to map
fig.plot(data=gpd_lines_new, pen="1p,steelblue")

fig.show()






michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
46 changes: 0 additions & 46 deletions examples/gallery/lines/roads.py

This file was deleted.

Loading