Update geopandas example
Please uncomment this block and take a look at this checklist if your PR is making substantial changes to documentation/impacts files in the doc directory. Check all that apply to your PR, and leave the rest unchecked to discuss with your reviewer! Not all boxes must be checked for every PR :)
If your PR modifies code of the plotly package, we have a different checklist
below :-).
Documentation PR
- [x] I've seen the
doc/README.mdfile - [x] This change runs in the current version of Plotly on PyPI and targets the
doc-prodbranch OR it targets themasterbranch - [x] If this PR modifies the first example in a page or adds a new one, it is a
pxexample if at all possible - [x] Every new/modified example has a descriptive title and motivating sentence or paragraph
- [x] Every new/modified example is independently runnable
- [x] Every new/modified example is optimized for short line count and focuses on the Plotly/visualization-related aspects of the example rather than the computation required to produce the data being visualized
- [x] Meaningful/relatable datasets are used for all new examples instead of randomly-generated data where possible
- [ ] The random seed is set if using randomly-generated data in new/modified examples
- [ ] New/modified remote datasets are loaded from https://plotly.github.io/datasets and added to https://github.com/plotly/datasets
- [x] Large computations are avoided in the new/modified examples in favour of loading remote datasets that represent the output of such computations
- [x] Imports are
plotly.graph_objects as go/plotly.express as px/plotly.io as pio - [x] Data frames are always called
df - [x]
fig = <something>call is high up in each new/modified example (eitherpx.<something>ormake_subplotsorgo.Figure) - [x] Liberal use is made of
fig.add_*andfig.update_*rather thango.Figure(data=..., layout=...)in every new/modified example - [x] Specific adders and updaters like
fig.add_shapeandfig.update_xaxesare used instead of bigfig.update_layoutcalls in every new/modified example - [x]
fig.show()is at the end of each new/modified example - [x]
plotly.plot()andplotly.iplot()are not used in any new/modified example - [ ] Hex codes for colors are not used in any new/modified example in favour of these nice ones
Code PR
- [ ] I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of
plotly.graph_objects, my modifications concern thecodegenfiles and not generated files. - [ ] I have added tests (if submitting a new feature or correcting a bug) or modified existing tests.
- [ ] For a new feature, I have added documentation examples in an existing or new tutorial notebook (please see the doc checklist as well).
- [ ] I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
- [ ] For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).
Notes:
- The example does not involve random data or new datasets, so those checklist items are not applicable.
- Used
projection="natural earth"to avoid the need for a Mapbox access token.
Testing:
- Tested with GeoPandas 0.9.0 (pre-1.0) and GeoPandas 1.9.0.
- The example runs successfully in both environments.
Related Issues:
- Fixes #4778
Let me know if there are any questions or if further changes are needed.
Thanks @sarthak-12 for the PR!
geodatasets might work for both versions. If so, we could get rid of the if/else
But we also may need to look at the datasets available on geodatasets and see if they are accessible in the same way.
df = gpd.read_file(geodatasets.get_path('naturalearth_cities'))
returns the following for me
raise ValueError(f"No matching item found for the query '{name}'.")
ValueError: No matching item found for the query 'naturalearth_cities'
It looks like the geopandas team simultaneously separated data sets into a separate project and removed the cities data set from their example library
The data appear to be available here: https://www.naturalearthdata.com/downloads/110m-cultural-vectors/ specifically, I think, here: http//www.naturalearthdata.com/download/110m/cultural/ne_110m_populated_places_simple.zip
if this code needs a file inside that zip, would you want it committed to the plotly data repo?
It looks like the geopandas team simultaneously separated data sets into a separate project and removed the cities data set from their example library
The data appear to be available here: https://www.naturalearthdata.com/downloads/110m-cultural-vectors/ specifically, I think, here: http//www.naturalearthdata.com/download/110m/cultural/ne_110m_populated_places_simple.zip
if this code needs a file inside that zip, would you want it committed to the plotly data repo?
Thanks @rl-utility-man
I think we could avoid committing the zip file. It looks like something like this would just work:
geo_df = gpd.read_file("https://naciscdn.org/naturalearth/110m/cultural/ne_110m_populated_places_simple.zip")
What do you think?
if gpd.read_file() just works on a ZIP, I like this solution. If we'd have to clutter the codebase with downloading and unzipping and need to deal with potential differences in the local file system, then perhaps putting a small geopandas point data set in the data repo would be cleaner. I feel no deep expertise or strong opinions here; I just hoped my prior comment would provide some context to move this toward a resolution.