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 all 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
46 changes: 46 additions & 0 deletions examples/gallery/lines/linestrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
GeoPandas: Plotting lines with LineString or MultiLineString geometry
=====================================================================

The :meth:`pygmt.Figure.plot` method allows us to plot geographical data such as lines
with LineString or MultiLineString geometry types stored in a
:class:`geopandas.GeoDataFrame` object or any object that implements the
`__geo_interface__ <https://gist.github.com/sgillies/2217756>`__ property.

Use :func:`geopandas.read_file` to load data from any supported OGR format such as a
shapefile (.shp), GeoJSON (.geojson), geopackage (.gpkg), etc. Then, pass the
:class:`geopandas.GeoDataFrame` object as an argument to the ``data`` parameter of
:meth:`pygmt.Figure.plot`, and style the lines using the ``pen`` parameter.
"""

# %%
import geodatasets
import geopandas as gpd
import pygmt

# Read a sample dataset provided by the geodatasets package.
# The dataset contains large rivers in Europe, stored as LineString/MultiLineString
# geometry types.
gdf = gpd.read_file(geodatasets.get_path("eea large_rivers"))

# Convert object to EPSG 4326 coordinate system
gdf = gdf.to_crs("EPSG:4326")
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
print(gdf.head())

# %%
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=gdf, pen="1p,steelblue")

fig.show()
46 changes: 0 additions & 46 deletions examples/gallery/lines/roads.py

This file was deleted.

Loading