11import pytest
2+ import pyarrow as pa
23from geoarrow import types
34import geoarrow .pyarrow as ga
45
@@ -23,18 +24,59 @@ def test_scalar_to_shapely():
2324 assert array [0 ].to_shapely ().wkt == "POINT (30 10)"
2425
2526
26- def test_to_geopandas ():
27- array = ga .array (["POINT (30 10)" ])
27+ def test_to_geopandas_unsupported_type ():
28+ # GeoPandas doesn't support geoarrow.wkt, so this goes through the branch
29+ # that handles any GeoPandas failure
30+ array = ga .as_wkt (["POINT (30 10)" ])
31+ geoseries = ga .to_geopandas (array )
32+ assert isinstance (geoseries , geopandas .GeoSeries )
33+ assert len (geoseries ) == 1
34+ assert geoseries .to_wkt ()[0 ] == "POINT (30 10)"
35+
36+
37+ def test_to_geopandas_using_geopandas ():
38+ array = ga .as_wkb (["POINT (30 10)" ])
2839 geoseries = ga .to_geopandas (array )
2940 assert isinstance (geoseries , geopandas .GeoSeries )
3041 assert len (geoseries ) == 1
3142 assert geoseries .to_wkt ()[0 ] == "POINT (30 10)"
3243
3344
3445def test_to_geopandas_with_crs ():
35- array = ga .with_crs (ga .array (["POINT (30 10)" ]), types .OGC_CRS84 )
46+ array = ga .with_crs (ga .as_wkt (["POINT (30 10)" ]), types .OGC_CRS84 )
47+ geoseries = ga .to_geopandas (array )
48+ assert isinstance (geoseries , geopandas .GeoSeries )
49+ assert len (geoseries ) == 1
50+ assert geoseries .to_wkt ()[0 ] == "POINT (30 10)"
51+ assert geoseries .crs .to_authority () == ("OGC" , "CRS84" )
52+
53+
54+ def test_to_geopandas_with_crs_using_geopandas ():
55+ array = ga .with_crs (ga .as_wkb (["POINT (30 10)" ]), types .OGC_CRS84 )
3656 geoseries = ga .to_geopandas (array )
3757 assert isinstance (geoseries , geopandas .GeoSeries )
3858 assert len (geoseries ) == 1
3959 assert geoseries .to_wkt ()[0 ] == "POINT (30 10)"
4060 assert geoseries .crs .to_authority () == ("OGC" , "CRS84" )
61+
62+
63+ def test_table_to_geopandas_unsupported_type ():
64+ # GeoPandas doesn't support geoarrow.wkt, so this goes through the branch
65+ # that handles any GeoPandas failure
66+ table = pa .table ({"geom" : ga .as_wkt (["POINT (30 10)" ])})
67+ gdf = ga .to_geopandas (table )
68+ assert isinstance (gdf , geopandas .GeoDataFrame )
69+
70+ geoseries = gdf .geometry
71+ assert len (geoseries ) == 1
72+ assert geoseries .to_wkt ()[0 ] == "POINT (30 10)"
73+
74+
75+ def test_table_to_geopandas_using_geopandas ():
76+ table = pa .table ({"geom" : ga .as_wkb (["POINT (30 10)" ])})
77+ gdf = ga .to_geopandas (table )
78+ assert isinstance (gdf , geopandas .GeoDataFrame )
79+
80+ geoseries = gdf .geometry
81+ assert len (geoseries ) == 1
82+ assert geoseries .to_wkt ()[0 ] == "POINT (30 10)"
0 commit comments