Why is GeoPandas overlay intersection empty between LINESTRING and MULTIPOLYGON geometries?

Viewed 37

I want to split British Columbia's road network by health regions. Specifically, for each health region I want to save a shape file of the roads within that region. The roads have a LINESTRING geometry while the health regions have a MULTIPOLYGON geometry.

I thought that the geopandas overlay with how=intersection might help me do this, but it telling me that the intersection is empty. That doesn't make sense in light of the fact that plotting (not shown) the roads and the health authorities together shows clear overlap, so I suspect I have misunderstood how geopandas handles intersection of different geometries.

Here is some minimum code, although it won't run unless you happen to locally have these files stored.

import geopandas as gpd
import matplotlib.pyplot as plt

health_regions_df = gpd.read_file(
    '../data/canada.geojson'
    )

bc_roads_df = gpd.read_file(
    '../data/geobase_nrn_rrn/bc/nrn_rrn_bc_shp_en.zip',
    layer='NRN_bc_14_0_ROADSEG'
    )

bc_roads_df.to_crs(
    'EPSG:4326', 
    inplace=True
)

bc_hrs = health_regions_df[health_regions_df['province'] == 'British Columbia']

intersection = gpd.overlay(bc_hrs, bc_roads_df, how='intersection')

print(intersection)

The above gives the following printout:

Empty GeoDataFrame
Columns: [fid, hr_uid, province, engname, frename, count, NID, ROADSEGID, ADRANGENID, DATASETNAM, SPECVERS, ACCURACY, ACQTECH, PROVIDER, CREDATE, REVDATE, METACOVER, ROADCLASS, RTNUMBER1, RTNUMBER2, RTNUMBER3, RTNUMBER4, RTNUMBER5, RTENAME1FR, RTENAME2FR, RTENAME3FR, RTENAME4FR, RTENAME1EN, RTENAME2EN, RTENAME3EN, RTENAME4EN, EXITNBR, NBRLANES, PAVSTATUS, PAVSURF, UNPAVSURF, STRUCTID, STRUCTTYPE, STRUNAMEEN, STRUNAMEFR, L_ADDDIRFG, L_HNUMF, L_HNUML, L_STNAME_C, L_PLACENAM, R_ADDDIRFG, R_HNUMF, R_HNUML, R_STNAME_C, R_PLACENAM, CLOSING, ROADJURIS, SPEED, TRAFFICDIR, geometry]
Index: []

Why is GeoPandas overlay intersection empty between LINESTRING and MULTIPOLYGON geometries?

0 Answers
Related