-
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
Which data to use for geopandas.GeoDataFrame choropleth example? #2786
Comments
Maybe read a URL directly?
|
Yes that works but unfortunately the fetched data does neither contain population values nor it's possible to filter e.g. for a specific continent/region like "Europe". |
I faced this issue when starting to work on possible figures for the PyGMT paper. So far I understood that there is now a separate repro from the geopandas organization for datasets: These datasets can be accessed: import geopandas
import geodatasets
airbnb = geopandas.read_file(geodatasets.get_path("geoda.airbnb")) It is possible to get more information about these datasets (please see https://geodatasets.readthedocs.io/en/latest/#how-to-use): import geodatasets
geodatasets.data Gives:
There also the complete URL can be found (directly via The dataset is read into a GeoDataFrame and can then be used for analysis and plotting, e.g., in PyGMT. I just tried this with the first dataset listed by import geopandas as gpd
import numpy as np
import pygmt
airbnb = gpd.read_file("https://geodacenter.github.io/data-and-lab//data/airbnb.zip")
fig = pygmt.Figure()
fig.coast(
region=[-88, -87.2, 41.6, 42.05],
projection="M10c",
frame=True,
water="lightblue",
land="gray90",
shorelines="1/1p,gray30",
)
pygmt.makecpt(
cmap="bilbao",
series=[np.min(airbnb["population"]), np.max(airbnb["population"]), 10],
continuous=True,
)
fig.plot(
data=airbnb[["population","geometry"]],
pen="0.2p,gray10",
close=True,
fill="+z",
cmap=True,
aspatial="Z=population",
)
fig.colorbar(frame="x+lPopulation")
fig.show()
# fig.savefig(fname="choropleth_airbnb_population.png") So, @michaelgrund maybe you can find in the overview at https://geodatasets.readthedocs.io/en/latest/introduction.html#what-is-the-geodatasets-data-object an interesting dataset which you can use for your gallery example? |
I didn't realize that I could load the file directly. I thought you also need to include the |
I wanted to continue on the choropleth example mentioned in #1374, however, in the meanwhile
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
raises a deprection warning saying the datasets will be removed in geopandas v1.0 (see discussion in #2751).Thus, we need to use another data source. Any ideas what can be used without to much effort and without adding further dependecies to PyGMT?
The text was updated successfully, but these errors were encountered: