geometry not found in axis

Viewed 31

I have two Geopandas dataframes. the schema looks like below.

inventoryid                 object
dsuid                       object
basinquantum                object
reservoir                   object
geometry                  geometry
crs_epsg                    object
buffer_dist                float64
buffer                    geometry

The second dataframe schema looks like this

API12              object
geometry         geometry
Basin              object

since first dataframe having two geometry types am setting geometry to buffer column

wells1=wells1.set_geometry("buffer")

I am performing intersection operation

res_intersection = gpd.overlay(wells2,wells1,how='intersection')

Although geometry column is present but still i am getting error like "['geometry'] not found in axis"

1 Answers
  • creating a repeatable section of code that matches your description
  • this does fail in my environment with a different error when using pygeos GEOSException: IllegalArgumentException: Argument must be Polygonal or LinearRing
    • will further work on this and if necessary raise BUG against geopandas
    • will try against main branch not just v0.11 and investigate other versions of pygeos and geos
  • this does work with rtree
import geopandas as gpd

pygeos = False
gpd._compat.set_use_pygeos(pygeos)

world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
cities = gpd.read_file(gpd.datasets.get_path("naturalearth_cities"))

# construct geodataframes logically equivalent to question
# two geometry columns
wells1 = cities.iloc[[11, 36, 50, 113, 158, 161, 172, 199]].copy()
wells1["buffer"] = (
    wells1.to_crs(wells1.estimate_utm_crs()).buffer(1.5 * 10**5).to_crs(wells1.crs)
)
wells1 = wells1.set_geometry("buffer")
wells2 = world.iloc[[43, 54, 55, 58, 82, 129, 130]].copy()

gdf_i = gpd.overlay(wells2, wells1, how="intersection")

gdf_i.explore(height=300, width=500)

output

enter image description here

Environment

gpd.get_versions()

SYSTEM INFO

python : 3.10.6 (main, Aug 30 2022, 05:11:14) [Clang 13.0.0 (clang-1300.0.29.30)] machine : macOS-11.6.8-x86_64-i386-64bit

GEOS, GDAL, PROJ INFO

GEOS : 3.11.0 GEOS lib : /usr/local/Cellar/geos/3.11.0/lib/libgeos_c.dylib GDAL : 3.4.1 PROJ : 9.1.0

PYTHON DEPENDENCIES

geopandas : 0.11.1 numpy : 1.23.3 pandas : 1.4.4 pyproj : 3.4.0 shapely : 1.8.4 fiona : 1.8.21 geoalchemy2: None geopy : None matplotlib : 3.5.3 mapclassify: 2.4.3 pygeos : 0.13 pyogrio : None psycopg2 : None pyarrow : None rtree : 1.0.0

Related