Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from init proj4 type projection #72

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion partridge/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.1"
__version__ = "1.1.1a0" ## modified partridge published by praneethd7 on 2022-12-15
7 changes: 3 additions & 4 deletions partridge/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
raise


DEFAULT_CRS = {"init": "EPSG:4326"}
DEFAULT_CRS = "EPSG:4326"


def build_shapes(df: pd.DataFrame) -> gpd.GeoDataFrame:
Expand All @@ -32,8 +32,7 @@ def build_stops(df: pd.DataFrame) -> gpd.GeoDataFrame:
if df.empty:
return gpd.GeoDataFrame(df, geometry=[], crs=DEFAULT_CRS)

df["geometry"] = df.apply(lambda s: Point(s.stop_lon, s.stop_lat), axis=1)

df = gpd.GeoDataFrame(df, crs=DEFAULT_CRS, geometry=gpd.points_from_xy(df.stop_lon,df.stop_lat))
df.drop(["stop_lon", "stop_lat"], axis=1, inplace=True)

return gpd.GeoDataFrame(df, crs={"init": "EPSG:4326"})
return df
2 changes: 1 addition & 1 deletion partridge/gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _read_csv(self, filename: str) -> pd.DataFrame:
with open(path, "rb") as f:
encoding = detect_encoding(f)

df = pd.read_csv(path, dtype=np.unicode, encoding=encoding, index_col=False)
df = pd.read_csv(path, dtype=np.str_, encoding=encoding, index_col=False)

# Strip leading/trailing whitespace from column names
df.rename(columns=lambda x: x.strip(), inplace=True)
Expand Down
2 changes: 1 addition & 1 deletion partridge/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ def detect_encoding(f: BinaryIO, limit: int = 2500) -> str:
def empty_df(columns: Optional[Iterable[str]] = None) -> pd.DataFrame:
columns = [] if columns is None else columns
empty: Dict = {col: [] for col in columns}
return pd.DataFrame(empty, columns=columns, dtype=np.unicode)
return pd.DataFrame(empty, columns=columns, dtype=np.str_)
4 changes: 2 additions & 2 deletions tests/test_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_load_geo_feed():
assert isinstance(feed.stops, gpd.GeoDataFrame)
assert {"LineString"} == set(feed.shapes.geom_type)
assert {"Point"} == set(feed.stops.geom_type)
assert feed.shapes.crs == {"init": "EPSG:4326"}
assert feed.stops.crs == {"init": "EPSG:4326"}
assert feed.shapes.crs == "EPSG:4326"
assert feed.stops.crs == "EPSG:4326"
assert ["shape_id", "geometry"] == list(feed.shapes.columns)
assert [
"stop_id",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_empty_df():
actual = empty_df(["foo", "bar"])

expected = pd.DataFrame(
{"foo": [], "bar": []}, columns=["foo", "bar"], dtype=np.unicode
{"foo": [], "bar": []}, columns=["foo", "bar"], dtype=np.str_
)

assert actual.equals(expected)
Expand Down