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 for plotting geopandas.GeoDataFrame objects #1374

Open
weiji14 opened this issue Jul 6, 2021 · 8 comments
Open

Add gallery example for plotting geopandas.GeoDataFrame objects #1374

weiji14 opened this issue Jul 6, 2021 · 8 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers help wanted Helping hands are appreciated

Comments

@weiji14
Copy link
Member

weiji14 commented Jul 6, 2021

Description of the desired feature

It would be great to have some gallery examples on how users can plot geopandas.GeoDataFrame objects in PyGMT. This will be a follow up to #1000. You will need to have some familiarity with geopandas and/or PyGMT, but if you're still keen to learn, let us know and we'll guide you along!

Note that if you are interested in writing a full tutorial for geopandas inputs, see #1268.

Examples of what you can do

These are just suggestions of things that you can plot. Feel free to come up with other ideas, especially if you know of a cool dataset! See also https://geopandas.org/gallery/index.html for inspiration

  1. Points: Capital cities in a region, Weather stations in a country, etc
  2. Lines: Road centrelines, etc
  3. Polygons: Geological map of a place, vegetation type/land cover map, etc

How to make the change 🧐

  1. First, read up our contributing guidelines at https://www.pygmt.org/v0.4.0/contributing.html#editing-the-documentation
  2. Leave a comment below, stating that you will tackle this issue. We will assign you to this issue and you can then start working on it.
  3. Go to e.g. https://github.com/GenericMappingTools/pygmt/tree/master/examples/gallery/maps, and click on 'Add File'. Or you may want to do this in your code editor locally.
  4. Submit a pull request, and be sure to fill it up with as much detail as possible.

Are you willing to help implement and maintain this feature? Happy to mentor someone to handle this task!

@weiji14 weiji14 added documentation Improvements or additions to documentation scipy-sprint Things to work on during the SciPy sprint! labels Jul 6, 2021
@maxrjones
Copy link
Member

Assigning this issue to @Location-Artistry who's requested to work on this issue for the SciPy2021 sprint 😄

@michaelgrund
Copy link
Member

I played a little bit around with a dataset containing the road net of the US in shapefile format (TIGER/Line shapefiles).

However, since the dataset is huge for the whole US I selected a subset containing only the road net of Hawai'i which is only around 2.5 MB (I made a zoom on O'ahu).

I think this would be enough to generate a nice example which shows how we could use shapefile data loaded via geopandas in PyGMT. My only question is: how and where do we want to store data for generating the geopandas examples?

TEST_map

@weiji14
Copy link
Member Author

weiji14 commented Aug 30, 2021

how and where do we want to store data for generating the geopandas examples?

We don't need to store it, it's possible to load the zipped shapefile data directly from the https url!

import geopandas as gpd

gdf = gpd.read_file("http://www2.census.gov/geo/tiger/TIGER2015/PRISECROADS/tl_2015_15_prisecroads.zip")
print(gdf.head())

produces:

        LINEARID      FULLNAME RTTYP  MTFCC  \
0  1104258643968  Puainako Exd     M  S1200   
1  1103933153286   Puanako Exd     M  S1200   
2  1103890709860  Puainako Exd     M  S1200   
3  1104486222576     Keaau Byp     M  S1200   
4  1104486197669     Keaau Byp     M  S1200   

                                            geometry  
0  LINESTRING (-155.11039 19.69256, -155.11070 19...  
1  LINESTRING (-155.14804 19.68121, -155.14938 19...  
2  LINESTRING (-155.15660 19.68084, -155.15641 19...  
3  LINESTRING (-155.03130 19.62267, -155.03204 19...  
4  LINESTRING (-155.02989 19.61407, -155.02981 19...  

Alternatively, we can use the built-in datasets in geopandas using gpd.datasets.get_path. See https://geopandas.org/gallery/polygon_plotting_with_folium.html for an example:

path = gpd.datasets.get_path('nybb')
gdf = gpd.read_file(path)
print(gdf.head())
   BoroCode       BoroName     Shape_Leng    Shape_Area  \
0         5  Staten Island  330470.010332  1.623820e+09   
1         4         Queens  896344.047763  3.045213e+09   
2         3       Brooklyn  741080.523166  1.937479e+09   
3         1      Manhattan  359299.096471  6.364715e+08   
4         2          Bronx  464392.991824  1.186925e+09   

                                            geometry  
0  MULTIPOLYGON (((970217.022 145643.332, 970227....  
1  MULTIPOLYGON (((1029606.077 156073.814, 102957...  
2  MULTIPOLYGON (((1021176.479 151374.797, 102100...  
3  MULTIPOLYGON (((981219.056 188655.316, 980940....  
4  MULTIPOLYGON (((1012821.806 229228.265, 101278...  

@weiji14 weiji14 added good first issue Good for newcomers help wanted Helping hands are appreciated and removed scipy-sprint Things to work on during the SciPy sprint! labels Aug 30, 2021
@michaelgrund
Copy link
Member

michaelgrund commented Aug 30, 2021

Thanks @weiji14. I recognized that's it's possible to load the zipped shapefile data directly from the url, however, I thought the loading procedure takes too long.

I added a PR addressing lines data in a geopandas.GeoDataFrame (#1474). Would suggest that this PR can serve as a starting point for new users which may add further examples using point and polygon data.

@yvonnefroehlich
Copy link
Member

yvonnefroehlich commented Apr 18, 2023

@GenericMappingTools/pygmt-maintainers I feel a choropleth map, like in the EGU 2021 Short Course, would be a further nice gallery example showing how to plot geopnadas-GeoDataFrame objects, in this case how to plot polygons.

@seisman
Copy link
Member

seisman commented Apr 18, 2023

@GenericMappingTools/pygmt-maintainers I feel a choropleth map, like in the EGU 2021 Short Course, would be a further nice gallery example showing how to plot geopnadas-GeoDataFrame objects, in this case how to plot polygons.

I agree. It's likely that @michaelgrund is working on a similar example in which he had the issue #2497.

@michaelgrund
Copy link
Member

@GenericMappingTools/pygmt-maintainers I feel a choropleth map, like in the EGU 2021 Short Course, would be a further nice gallery example showing how to plot geopnadas-GeoDataFrame objects, in this case how to plot polygons.

I agree. It's likely that @michaelgrund is working on a similar example in which he had the issue #2497.

Exactly, the issue came up while working on a gallery example which shows the usage of polygons. Will push the early stages in the next few days 😉

@yvonnefroehlich
Copy link
Member

@GenericMappingTools/pygmt-maintainers I feel a choropleth map, like in the EGU 2021 Short Course, would be a further nice gallery example showing how to plot geopnadas-GeoDataFrame objects, in this case how to plot polygons.

I agree. It's likely that @michaelgrund is working on a similar example in which he had the issue #2497.

Exactly, the issue came up while working on a gallery example which shows the usage of polygons. Will push the early stages in the next few days wink

No worries 🙂. I did not work on a specific gallery example so far. But I saw that we do not have a choropleth map in the gallery (only in the Short Course, which is probably not so easy to find), when thinking about potential figures for the PyGMT paper. So @michaelgrund go ahead and submit a PR with your ideas 🚀.

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 good first issue Good for newcomers help wanted Helping hands are appreciated
Projects
None yet
Development

No branches or pull requests

5 participants