Visitar URL original
ruff: Fix ICN002 geopandas import alias by seisman · Pull Request #4430 · GenericMappingTools/pygmt · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/gallery/lines/linestrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
"""

# %%
import geopandas as gpd
import geopandas
import pygmt

# Read a sample dataset provided by Natural Earth. The dataset contains rivers stored
# as LineString/MultiLineString geometry types. Here will focus on Asia.
provider = "https://naciscdn.org/naturalearth"
rivers = gpd.read_file(f"{provider}/50m/physical/ne_50m_rivers_lake_centerlines.zip")
rivers = geopandas.read_file(
f"{provider}/50m/physical/ne_50m_rivers_lake_centerlines.zip"
)
rivers_asia = rivers.cx[57:125, 7:47].copy()

fig = pygmt.Figure()
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/maps/choropleth_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"""

# %%
import geopandas as gpd
import geopandas
import pygmt
from pygmt.params.position import Position

provider = "https://naciscdn.org/naturalearth"
world = gpd.read_file(f"{provider}/110m/cultural/ne_110m_admin_0_countries.zip")
world = geopandas.read_file(f"{provider}/110m/cultural/ne_110m_admin_0_countries.zip")

# The dataset contains different attributes, here we focus on the population within
# the different countries (column "POP_EST") for the continent "Africa".
Expand Down
6 changes: 4 additions & 2 deletions examples/gallery/symbols/points_cities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
"""

# %%
import geopandas as gpd
import geopandas
import pygmt

# Read a sample dataset provided by Natural Earth. The dataset contains cities stored
# as Point geometry type. In this example we focus on Europe.
provider = "https://naciscdn.org/naturalearth"
cities = gpd.read_file(f"{provider}/50m/cultural/ne_50m_populated_places_simple.zip")
cities = geopandas.read_file(
f"{provider}/50m/cultural/ne_50m_populated_places_simple.zip"
)
cities = cities[cities["name"] != "Vatican City"].copy() # No overlap with label Rome
# Create two subsets for small and large cities
cities_small = cities[cities["worldcity"] != 1].copy()
Expand Down
6 changes: 3 additions & 3 deletions examples/intro/04_table_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# %%
from pathlib import Path

import geopandas as gpd
import geopandas
import numpy as np
import pandas as pd
import pygmt
Expand Down Expand Up @@ -98,9 +98,9 @@
# GMT and PyGMT do not support natively.

# Example GeoDataFrame
gdf = gpd.GeoDataFrame(
gdf = geopandas.GeoDataFrame(
{
"geometry": gpd.points_from_xy([2, 5, 9], [2, 3, 4]),
"geometry": geopandas.points_from_xy([2, 5, 9], [2, 3, 4]),
"value": [10, 20, 30],
}
)
Expand Down
4 changes: 2 additions & 2 deletions pygmt/helpers/tempfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def tempfile_from_geojson(geojson):
E.g. '1a2b3c4d5e6.gmt'.
"""
with GMTTempFile(suffix=".gmt") as tmpfile:
import geopandas as gpd # noqa: PLC0415
import geopandas # noqa: PLC0415

Path(tmpfile.name).unlink() # Ensure file is deleted first
ogrgmt_kwargs = {
Expand Down Expand Up @@ -165,7 +165,7 @@ def tempfile_from_geojson(geojson):
import json # noqa: PLC0415

jsontext = json.dumps(geojson.__geo_interface__)
gpd.read_file(filename=io.StringIO(jsontext)).to_file(**ogrgmt_kwargs)
geopandas.read_file(filename=io.StringIO(jsontext)).to_file(**ogrgmt_kwargs)

yield tmpfile.name

Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def choropleth(

Examples
--------
>>> import geopandas as gpd
>>> import geopandas
>>> import pygmt
>>> world = gpd.read_file(
>>> world = geopandas.read_file(
... "https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
... )
>>> world["POP_EST"] *= 1e-6 # Population in millions
Expand Down
4 changes: 2 additions & 2 deletions pygmt/tests/test_choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import pytest
from pygmt import Figure, makecpt

gpd = pytest.importorskip("geopandas")
geopandas = pytest.importorskip("geopandas")


@pytest.fixture(scope="module", name="world")
def fixture_world():
"""
Download and cache the Natural Earth countries dataset for testing.
"""
return gpd.read_file(
return geopandas.read_file(
"https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
)

Expand Down
16 changes: 8 additions & 8 deletions pygmt/tests/test_geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pygmt.helpers import data_kind
from pygmt.helpers.testing import skip_if_no

gpd = pytest.importorskip("geopandas")
geopandas = pytest.importorskip("geopandas")
shapely = pytest.importorskip("shapely")


Expand All @@ -36,7 +36,7 @@ def fixture_gdf():
}
)
# Multipolygon first so the OGR_GMT file has @GMULTIPOLYGON in the header
gdf = gpd.GeoDataFrame(
gdf = geopandas.GeoDataFrame(
index=["multipolygon", "polygon", "linestring"],
geometry=[multipolygon, polygon, linestring],
)
Expand All @@ -54,7 +54,7 @@ def fixture_gdf_ridge():
fname=["@RidgeTest.shp", "@RidgeTest.shx", "@RidgeTest.dbf", "@RidgeTest.prj"],
download="c",
)
gdf = gpd.read_file(shapefile[0])
gdf = geopandas.read_file(shapefile[0])
# Reproject the geometry
gdf["geometry"] = (
gdf.to_crs(crs="EPSG:3857")
Expand Down Expand Up @@ -98,7 +98,7 @@ def test_geopandas_plot_default_square():
2d.
"""
point = shapely.geometry.Point(1, 2)
gdf = gpd.GeoDataFrame(geometry=[point])
gdf = geopandas.GeoDataFrame(geometry=[point])
fig = Figure()
fig.plot(data=gdf, region=[0, 2, 1, 3], projection="X2c", frame=True)
return fig
Expand All @@ -111,7 +111,7 @@ def test_geopandas_plot3d_default_cube():
geometry in 3d.
"""
multipoint = shapely.geometry.MultiPoint([(0.5, 0.5, 0.5), (1.5, 1.5, 1.5)])
gdf = gpd.GeoDataFrame(geometry=[multipoint])
gdf = geopandas.GeoDataFrame(geometry=[multipoint])
fig = Figure()
fig.plot3d(
data=gdf,
Expand All @@ -131,7 +131,7 @@ def test_geopandas_plot_non_default_circle():
2d.
"""
point = shapely.geometry.Point(1, 2)
gdf = gpd.GeoDataFrame(geometry=[point])
gdf = geopandas.GeoDataFrame(geometry=[point])
fig = Figure()
fig.plot(data=gdf, region=[0, 2, 1, 3], projection="X2c", frame=True, style="c0.2c")
return fig
Expand All @@ -144,7 +144,7 @@ def test_geopandas_plot3d_non_default_circle():
in 3d.
"""
multipoint = shapely.geometry.MultiPoint([(0.5, 0.5, 0.5), (1.5, 1.5, 1.5)])
gdf = gpd.GeoDataFrame(geometry=[multipoint])
gdf = geopandas.GeoDataFrame(geometry=[multipoint])
fig = Figure()
fig.plot3d(
data=gdf,
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_geopandas_nonascii():
(1, 3),
]
)
gdf = gpd.GeoDataFrame(
gdf = geopandas.GeoDataFrame(
{
"name_ascii": ["Fiji"],
"name_utf8": ["فيجي"], # Arabic
Expand Down
Loading