Skip to content

Commit

Permalink
BUG: Handle missing geometry with to_crs and shapely (geopandas#1618)
Browse files Browse the repository at this point in the history
* BUG: Handle missing geometry with to_crs and shapely

* remove pygeos compat stuff in tests
  • Loading branch information
snowman2 authored Sep 14, 2020
1 parent 5616ba4 commit d693267
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion geopandas/_vectorized.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions geopandas/tests/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d693267

Please sign in to comment.