-
Notifications
You must be signed in to change notification settings - Fork 1
Figure 6: GeoPandas / spatial data - choropleth map - area with rivers and cities of the states of the USA #6
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
Open
yvonnefroehlich
wants to merge
77
commits into
main
Choose a base branch
from
fig/geopandas
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
f781946
Add draft of JN for geopandas - geodataframes with lines and polygons
yvonnefroehlich 93afa24
Include output figure
yvonnefroehlich 587da3a
Reduce resolution of output image in JN
yvonnefroehlich fc103e9
Follow coding style
yvonnefroehlich 57511d0
Adjust filename
yvonnefroehlich 01812e8
Remove comments | Improve code structure
yvonnefroehlich e288455
Move to normal python script (temporaly)
yvonnefroehlich fb445fd
Rename files and save output figure
yvonnefroehlich 6c58129
Add codes for choropleth map based on dcw parameter
yvonnefroehlich 0e321e0
Merge remote-tracking branch 'origin/main' into fig/geopandas
yvonnefroehlich c885c52
Add code for example covering points, lines, and polygons
yvonnefroehlich ab2ca00
Remove code for chorophleth via dcw
yvonnefroehlich c6a39c1
Remove unneeded files
yvonnefroehlich 65c458b
Adjust codes for example with natural earth data | temporly focus on …
yvonnefroehlich 012e5fb
Test different regions
yvonnefroehlich 8cb2e58
Remove content for Cicago example
yvonnefroehlich af55d14
Change scaling to e-6
yvonnefroehlich 7042382
Use 1e-6
yvonnefroehlich 40f4390
Adjust figure number
yvonnefroehlich dd18459
Adjust color and remove unneeded pen color
yvonnefroehlich 80a0648
Focus on Africa
yvonnefroehlich 8996b68
Use different symobl fill and size for world and smaller cities
yvonnefroehlich f979b8b
Adjust fill, outline and offset of text labels
yvonnefroehlich fb6e595
Adjust maximum for CPT to 100
yvonnefroehlich a3218a5
Follow coding style
yvonnefroehlich 8938542
No need to explecitly select the "geometry" column
yvonnefroehlich ad7a1bd
Adjust provider | Fix geopandas warning | Use full line length
yvonnefroehlich 61c98f1
Add backslash
yvonnefroehlich cba722d
Merge remote-tracking branch 'origin/main' into fig/geopandas
yvonnefroehlich b19ddf0
Adust colormap maximum and colorbar
yvonnefroehlich 561bb43
Adjust color for rivers
yvonnefroehlich f1eb469
Adjust text labels
yvonnefroehlich bedf467
Add just colorbar frame
yvonnefroehlich 447c51b
Plot colorbar verticall inside the map
yvonnefroehlich 6e84e65
Update output image
yvonnefroehlich 686b661
Adjust region
yvonnefroehlich 74bcc3a
TEMPORALY add code for focus on Africa
yvonnefroehlich 2d60504
Remove geometry column
yvonnefroehlich 324af82
Use rivers for 110 m
yvonnefroehlich 6eca7da
Update output image
yvonnefroehlich d0f4920
Merge remote-tracking branch 'origin/main' into fig/geopandas
yvonnefroehlich 645ff9c
Adjust and shorten variable names
yvonnefroehlich b119528
Use gpd.sjoin instead of pd.concat
yvonnefroehlich 3ed5e1f
Remove unneeded pandas import
yvonnefroehlich 2b4c6b9
Adjust building the city subsets
yvonnefroehlich 7bd7935
Use 110 m also for population
yvonnefroehlich c45cc6f
Remove geometry column
yvonnefroehlich ae24b2e
Remove code for old version
yvonnefroehlich dc38ff0
Update output images
yvonnefroehlich 9effeee
Remove geometry column
yvonnefroehlich 45b56ed
Merge remote-tracking branch 'origin/main' into fig/geopandas
yvonnefroehlich 1653b66
Add codes for Chicago map
yvonnefroehlich 4ba60d6
Improve visualization
yvonnefroehlich 269765d
Add lake
yvonnefroehlich 6c2c772
Merge remote-tracking branch 'origin/main' into fig/geopandas
yvonnefroehlich 07d84c9
Polish code
yvonnefroehlich 1e537a4
Update output figure
yvonnefroehlich 86fbfa7
Use Box class
yvonnefroehlich 1adf58f
Merge remote-tracking branch 'origin/main' into fig/geopandas
yvonnefroehlich 8d07359
Add draft for usa area chorophlet map with rivers and cities
yvonnefroehlich 1de1fd6
Adjust color of rivers
yvonnefroehlich 6ad8285
Start colormap at zero
yvonnefroehlich 97789ee
Update output image
yvonnefroehlich 13c3d3c
Do not subset cities | Use rivers from 110 m dataset | Remove geometr…
yvonnefroehlich 08bbc86
Improve data request
yvonnefroehlich a811284
Select rivers and cities located in USA
yvonnefroehlich 8a5daaa
Exclude Alaska | Increase thickness of colorbar | Upate output figure
yvonnefroehlich 8eb566a
Remove codes and images of old examples
yvonnefroehlich 477e7b4
Plot Alaska and Hawaii at the lower-left corner
yvonnefroehlich 0826ef4
Do not exclude Alaska
yvonnefroehlich 785502d
Remove codes from old examples
yvonnefroehlich a7f3262
Adjust position of colorbar
yvonnefroehlich 7d01582
Combine into loop
yvonnefroehlich 42693a2
Adjust colorbar | Improve comment
yvonnefroehlich 55dc3fb
Add missing word
yvonnefroehlich ae06ce9
Improve preparing the subsets
yvonnefroehlich e1121f2
Use color map hawaii
yvonnefroehlich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": 1, | ||
| "id": "760146f6-d4c9-4e69-b539-f42e057c7945", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Copy finale version of script from normal Python file" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "kernelspec": { | ||
| "display_name": "Python 3 (ipykernel)", | ||
| "language": "python", | ||
| "name": "python3" | ||
| }, | ||
| "language_info": { | ||
| "codemirror_mode": { | ||
| "name": "ipython", | ||
| "version": 3 | ||
| }, | ||
| "file_extension": ".py", | ||
| "mimetype": "text/x-python", | ||
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.12.3" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import geopandas as gpd | ||
| import pygmt | ||
|
|
||
| fig = pygmt.Figure() | ||
|
|
||
| fig.basemap(region=[-88, -87.5, 41.64, 42.04], projection="M9c", frame="rtlb") | ||
|
|
||
| gdf_airbnb = gpd.read_file("https://geodacenter.github.io/data-and-lab//data/airbnb.zip") | ||
| popul_min = gdf_airbnb["population"].min() | ||
| popul_max = gdf_airbnb["population"].max() | ||
|
|
||
| pygmt.makecpt(cmap="SCM/bilbao", series=[popul_min, popul_max, 10]) | ||
| fig.colorbar(frame="x+lpopulation", position="jBL+jBL+o0.5c/0c+v") | ||
| fig.plot( | ||
| data=gdf_airbnb, | ||
| pen="0.2p,gray10", | ||
| fill="+z", | ||
| cmap=True, | ||
| aspatial="Z=population", | ||
| ) | ||
|
|
||
| fig.show() | ||
| fig.savefig(fname="Fig7_PyGMT_geopandas.png") | ||
|
|
||
|
|
||
| # %% | ||
| import pygmt | ||
| import geopandas as gpd | ||
|
|
||
| region = "=SA" | ||
| region = [-89, -33, -56.5, 9.7] | ||
|
|
||
| world = gpd.read_file("https://naciscdn.org/naturalearth/50m/cultural/ne_50m_admin_0_countries.zip") | ||
| rivers = gpd.read_file("https://naciscdn.org/naturalearth/110m/physical/ne_110m_rivers_lake_centerlines.zip") | ||
| cities = gpd.read_file("https://naciscdn.org/naturalearth/110m/cultural/ne_110m_populated_places_simple.zip") | ||
|
|
||
| world["POP_EST"] *= 1.0e-5 | ||
|
|
||
| fig = pygmt.Figure() | ||
| fig.basemap(region=region, projection="M15c", frame=True) | ||
| pygmt.makecpt(cmap="batlow", series=(0, 2700, 100)) # 30000 | ||
yvonnefroehlich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot( | ||
| data=world[["POP_EST", "geometry"]], | ||
| pen="1p,gray50", | ||
| fill="+z", | ||
| cmap=True, | ||
| aspatial="Z=POP_EST", | ||
| ) | ||
| fig.colorbar(frame=["x+lPopulation", "y+l*10e-5"]) | ||
yvonnefroehlich marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fig.plot(data=rivers["geometry"], pen="1.5p,skyblue") | ||
| fig.plot(data=cities["geometry"], style="s0.3c", fill="red", pen="1p,black") | ||
| fig.text( | ||
| x=cities.geometry.x, | ||
| y=cities.geometry.y, | ||
| text=cities["name"], | ||
| font="10p,Helvetica-Bold,black", | ||
| offset="0c/-0.3c", | ||
| justify="TR", | ||
| fill="white@30", | ||
| ) | ||
| fig.show() | ||
| fig.savefig(fname="Fig7_PyGMT_geopandas_ne.png") | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.