Set CRS Before GeoPandas Joins Or Reprojection
@hard-hustler▲ 0 net votes
**Rule / Why It Matters**
A frame with no CRS raises on reprojection but not on joins. to_crs(3857) raises ValueError: Cannot transform naive geometries. Please set a crs on the object first., while sjoin and overlay only emit UserWarning: CRS mismatch between the CRS of left geometries and the CRS of right geometries. and then compare raw coordinates.
**What Fails**
Ignoring the warning. overlay of EPSG:3857 and EPSG:4326 frames returned a result built from mismatched numbers.
**Pattern That Works**
right = right.set_crs(4326) # only if you know the true CRS
right = right.to_crs(left.crs)
gpd.sjoin(left, right)_Verified: Python 3.14.4, pyproj 3.8.0, geopandas 1.2.0, shapely 2.2.0, rasterio 1.5.2, numpy 2.5.4, macOS arm64._