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

Add gallery example showing usage of line objects from a geopandas.GeoDataFrame #1474

Merged
merged 16 commits into from
Sep 10, 2021

Conversation

michaelgrund
Copy link
Member

@michaelgrund michaelgrund commented Aug 30, 2021

Description of proposed changes

Here's the first gallery example showcasing how to plot line objects stored in a geopandas.GeoDataFrame (see #1374).

Preview at https://pygmt-git-gallery-gpd-lines-gmt.vercel.app/gallery/maps/roads.html

Roads gallery example

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 adding new functionality, add an example to docstrings or tutorials.

Slash Commands

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

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

…s.GeoDataFrame

Here's the first gallery example showcasing how to plot line objects stored in a geopandas.GeoDataFrame.
@michaelgrund michaelgrund added the documentation Improvements or additions to documentation label Aug 30, 2021
@michaelgrund michaelgrund added this to the 0.5.0 milestone Aug 30, 2021
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Thanks @michaelgrund! This geopandas example will be a nice addition to the gallery 😁

To fix the failing CI docs test, you'll need to add geopandas as a dependency at

conda install gmt=6.2.0 numpy pandas xarray netCDF4 packaging \
ipython make myst-parser \

examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
michaelgrund added a commit that referenced this pull request Sep 3, 2021
Related to #1474, this PR adds the geopandas library as a dependency in the CI docs test.
@michaelgrund
Copy link
Member Author

Thanks @michaelgrund! This geopandas example will be a nice addition to the gallery 😁

To fix the failing CI docs test, you'll need to add geopandas as a dependency at

conda install gmt=6.2.0 numpy pandas xarray netCDF4 packaging \
ipython make myst-parser \

Added in #1481.

@weiji14
Copy link
Member

weiji14 commented Sep 3, 2021

Unrelated test failure due to setuptools_scm v6.3.0 having some error about missing tomli (see pypa/setuptools-scm#608). They've released v6.3.1 so should be all good now, restarting tests.

Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Just two more comments from me, otherwise ready for final review. Will give it until the end of the week (Friday 10/9/2021) since it's a public holiday in the US.

Comment on lines 26 to 30
fig.basemap(
region=region,
projection="M12c",
frame=["af", 'WSne+t"Main roads of Oahu (Hawaii)"'],
)
Copy link
Member

Choose a reason for hiding this comment

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

I've figured it out! We can use the octal code for apostrophe (') which is 047, see https://docs.generic-mapping-tools.org/6.2/cookbook/octal-codes.html.

Suggested change
fig.basemap(
region=region,
projection="M12c",
frame=["af", 'WSne+t"Main roads of Oahu (Hawaii)"'],
)
title = r"Main roads of O\047ahu (Hawai\047i)" # \047 is octal code for '
fig.basemap(region=region, projection="M12c", frame=["af", f'WSne+t"{title}"'])

Copy link
Member Author

Choose a reason for hiding this comment

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

Great @weiji14!

Copy link
Member

Choose a reason for hiding this comment

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

Realizing two years later that I used the wrong symbol 😅 It should be an Okina ʻ (U+02BB) instead of an apostrophe. Looks more like a 6 than a 9.

examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
@weiji14 weiji14 added the final review call This PR requires final review and approval from a second reviewer label Sep 6, 2021
Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

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

The example looks good to me, but I'm not sure if we should put the example in the "Maps and map elements" or the "Lines and vectors" category.

examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
examples/gallery/maps/roads.py Outdated Show resolved Hide resolved
@michaelgrund
Copy link
Member Author

The example looks good to me, but I'm not sure if we should put the example in the "Maps and map elements" or the "Lines and vectors" category.

Of course, we should definitely discuss that before merging. Would be happy with both categories since the example contains elements that would fit into both.

Copy link
Contributor

@willschlitzer willschlitzer left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@seisman
Copy link
Member

seisman commented Sep 9, 2021

The example looks good to me, but I'm not sure if we should put the example in the "Maps and map elements" or the "Lines and vectors" category.

Of course, we should definitely discuss that before merging. Would be happy with both categories since the example contains elements that would fit into both.

I prefer to have this example in the "Lines and vectors" category, because the example focuses on plotting lines from GeoDataFrame, rather than plotting a map.

@michaelgrund
Copy link
Member Author

I prefer to have this example in the "Lines and vectors" category, because the example focuses on plotting lines from GeoDataFrame, rather than plotting a map.

Done!

Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@seisman seisman changed the title Gallery example showing usage of line objects from a geopandas.GeoDataFrame Add gallery example showing usage of line objects from a geopandas.GeoDataFrame Sep 9, 2021
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.

4 participants