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 gpd lines gallery example #3711

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

michaelgrund
Copy link
Member

@michaelgrund michaelgrund commented Dec 24, 2024

Description of proposed changes

Fixes #3320

Preview: https://pygmt-dev--3711.org.readthedocs.build/en/3711/gallery/lines/linestrings.html#

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@michaelgrund michaelgrund added the documentation Improvements or additions to documentation label Dec 24, 2024
@michaelgrund michaelgrund added this to the 0.14.0 milestone Dec 24, 2024
@michaelgrund michaelgrund marked this pull request as draft December 24, 2024 14:46
@seisman
Copy link
Member

seisman commented Dec 25, 2024

Two thoughts:

  1. Perhaps we should have geodatasets installed in our CI, so that we don't have to have the long URL hardcoded.
  2. The title "Rivers" gives me the expression that this is about a river dataset, but actually it's all about plotting LineString/MultiLineString geometries in GeoPandas objects (or geojson format). Maybe rename the title to something like "Plotting lines with LineString/MultiLineString geometry", "GeoPandas: Lines with LineString/MultiLineString geometry"

@michaelgrund
Copy link
Member Author

Two thoughts:

1. Perhaps we should have [`geodatasets`](https://github.com/geopandas/geodatasets) installed in our CI, so that we don't have to have the long URL hardcoded.

2. The title "Rivers" gives me the expression that this is about a river dataset, but actually it's all about plotting LineString/MultiLineString geometries in GeoPandas objects (or geojson format). Maybe rename the title to something like "Plotting lines with LineString/MultiLineString geometry", "GeoPandas: Lines with LineString/MultiLineString geometry"

Agree with both points. Regarding point 1 we just want to add it for the docs/gallery example and not as an general dependency, right?

@seisman
Copy link
Member

seisman commented Dec 25, 2024

Two thoughts:

1. Perhaps we should have [`geodatasets`](https://github.com/geopandas/geodatasets) installed in our CI, so that we don't have to have the long URL hardcoded.

2. The title "Rivers" gives me the expression that this is about a river dataset, but actually it's all about plotting LineString/MultiLineString geometries in GeoPandas objects (or geojson format). Maybe rename the title to something like "Plotting lines with LineString/MultiLineString geometry", "GeoPandas: Lines with LineString/MultiLineString geometry"

Agree with both points. Regarding point 1 we just want to add it for the docs/gallery example and not as an general dependency, right?

Yes.

@yvonnefroehlich
Copy link
Member

Regarding point 1, this would be also relevant / helpful for the Gallery example Choropleth map.

@seisman
Copy link
Member

seisman commented Dec 25, 2024

Regarding point 1, this would be also relevant / helpful for the Gallery example Choropleth map.

Maybe we should add geodatasets and update the Choropleth example in a separate PR first.

@seisman
Copy link
Member

seisman commented Dec 25, 2024

Regarding point 1, this would be also relevant / helpful for the Gallery example Choropleth map.

Maybe we should add geodatasets and update the Choropleth example in a separate PR first.

I'll open a PR in minites.

examples/gallery/lines/linestrings.py Outdated Show resolved Hide resolved
examples/gallery/lines/linestrings.py Outdated Show resolved Hide resolved
@michaelgrund
Copy link
Member Author

/format

examples/gallery/lines/linestrings.py Outdated Show resolved Hide resolved
examples/gallery/lines/linestrings.py Outdated Show resolved Hide resolved
@@ -0,0 +1,39 @@
"""
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


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

Comment on lines +5 to +7
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.

Please wrap these lines to 88 characters.

gdf = gpd.read_file(geodatasets.get_path("eea large_rivers"))

# Convert object to EPSG 4326 coordinate system
gdf = gdf.to_crs("EPSG:4326")
Copy link
Member

Choose a reason for hiding this comment

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

Check the content of the data before plotting.

Suggested change
gdf = gdf.to_crs("EPSG:4326")
gdf = gdf.to_crs("EPSG:4326")
print(gdf)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use a different dataset in the gallery example "examples/gallery/lines/roads.py"
4 participants