-
Notifications
You must be signed in to change notification settings - Fork 224
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
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
3696994
Update gpd lines gallery example
michaelgrund c6bfba4
update
michaelgrund 8c5bfa8
update name
michaelgrund db9915b
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund d222759
Apply suggestions from code review
michaelgrund 47dabbc
Apply suggestions from code review
michaelgrund 1dbebb5
remove empty rows
michaelgrund 45c04fa
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund 17284c2
update
michaelgrund e4442a3
update
michaelgrund 23ba61a
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund 97aaa81
[format-command] fixes
actions-bot 736e519
add data via geodatasets
michaelgrund 3d9703a
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund b4fa12c
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund 76ed9de
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund b3e0e27
Apply suggestions from code review
michaelgrund 2231241
fix typo
michaelgrund d2dc007
Update linestrings.py
michaelgrund 8087c1c
Apply suggestions from code review
michaelgrund 72d2cc1
Wrap line to 88 chars
michaelgrund b7fab6d
Merge branch 'main' into upd-gpd-lines-gallery
michaelgrund 573309c
rm trailing ws
michaelgrund ac4b31d
Apply suggestions from code review
seisman 49e9816
Merge branch 'main' into upd-gpd-lines-gallery
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||
""" | ||||||
Plotting lines with LineString/MultiLineString geometry | ||||||
======================================================= | ||||||
yvonnefroehlich 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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 geodatasets | ||||||
import geopandas as gpd | ||||||
import pygmt | ||||||
|
||||||
# Read shapefile data of large rivers in Europe using geopandas | ||||||
seisman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
gdf = gpd.read_file(geodatasets.get_path("eea large_rivers")) | ||||||
|
||||||
# Convert object to EPSG 4326 coordinate system | ||||||
gpd = gpd.to_crs("EPSG:4326") | ||||||
michaelgrund marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
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, pen="1p,steelblue") | ||||||
michaelgrund marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
fig.show() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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: