mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-23 13:20:36 +08:00
BUG: Handle missing geometry with to_crs and shapely (#1618)
* BUG: Handle missing geometry with to_crs and shapely * remove pygeos compat stuff in tests
This commit is contained in:
@@ -886,6 +886,9 @@ def transform(data, func):
|
||||
result = np.empty(n, dtype=object)
|
||||
for i in range(n):
|
||||
geom = data[i]
|
||||
result[i] = transform(func, geom)
|
||||
if _isna(geom):
|
||||
result[i] = geom
|
||||
else:
|
||||
result[i] = transform(func, geom)
|
||||
|
||||
return result
|
||||
|
||||
@@ -49,6 +49,15 @@ def test_to_crs_transform():
|
||||
assert_geodataframe_equal(df, utm, check_less_precise=True)
|
||||
|
||||
|
||||
def test_to_crs_transform__missing_data():
|
||||
# https://github.com/geopandas/geopandas/issues/1573
|
||||
df = df_epsg26918()
|
||||
df.loc[3, "geometry"] = None
|
||||
lonlat = df.to_crs(epsg=4326)
|
||||
utm = lonlat.to_crs(epsg=26918)
|
||||
assert_geodataframe_equal(df, utm, check_less_precise=True)
|
||||
|
||||
|
||||
def test_to_crs_inplace():
|
||||
df = df_epsg26918()
|
||||
lonlat = df.to_crs(epsg=4326)
|
||||
|
||||
Reference in New Issue
Block a user