diff --git a/setup.py b/setup.py index 965a20e..47cf4f0 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ }, keywords=["gis"], install_requires=[ - "arcgis==2.3.*", + "arcgis>=2.3,<2.5", "geopandas>=0.14,<1.1", "geodatasets>=2023.12,<2024.9", "pg8000>=1.29,<1.32", diff --git a/src/palletjack/extract.py b/src/palletjack/extract.py index 275584b..f7e200d 100644 --- a/src/palletjack/extract.py +++ b/src/palletjack/extract.py @@ -500,7 +500,7 @@ def __init__(self, host, database, username, password, port=5432): self._class_logger = logging.getLogger(__name__).getChild(self.__class__.__name__) if utils.is_running_in_gcp(): - self._class_logger.info("running in GCF, using unix socket") + self._class_logger.info("running in GCP, using unix socket") self.engine = sqlalchemy.create_engine( sqlalchemy.engine.url.URL.create( drivername="postgresql+pg8000", @@ -543,9 +543,6 @@ def read_table_into_dataframe(self, table_name, index_column, crs, spatial_colum ) spatial_dataframe = pd.DataFrame.spatial.from_geodataframe(dataframe, column_name=spatial_column) - for column in spatial_dataframe.select_dtypes(include=["datetime64[ns, UTC]"]): - self._class_logger.debug("Converting column `%s` to ISO string format", column) - spatial_dataframe[column] = spatial_dataframe[column].apply(pd.Timestamp.isoformat) self._class_logger.debug("Dataframe shape: %s", spatial_dataframe.shape) if len(spatial_dataframe.index) == 0: diff --git a/src/palletjack/utils.py b/src/palletjack/utils.py index 64a711c..abee553 100644 --- a/src/palletjack/utils.py +++ b/src/palletjack/utils.py @@ -380,9 +380,9 @@ def sedf_to_gdf(dataframe): gdf = gpd.GeoDataFrame(dataframe, geometry=dataframe.spatial.name) try: - gdf.set_crs(dataframe.spatial.sr["latestWkid"], inplace=True) - except KeyError: - gdf.set_crs(dataframe.spatial.sr["wkid"], inplace=True) + gdf.set_crs(dataframe.spatial.sr.latestWkid, inplace=True) + except AttributeError: + gdf.set_crs(dataframe.spatial.sr.wkid, inplace=True) return gdf diff --git a/tests/test_utils.py b/tests/test_utils.py index 55489a1..5eafe1e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,7 +5,6 @@ from pathlib import Path import numpy as np -import palletjack import pandas as pd import pyogrio import pytest @@ -13,6 +12,8 @@ from arcgis.features import FeatureLayer, Table from pandas import testing as tm +import palletjack + @pytest.fixture(scope="module") #: only call this once per module def iris(): @@ -1833,15 +1834,19 @@ def test_chunker(self): class TestSEDFtoGDF: def test_sedf_to_gdf_uses_wkid_when_missing_latestwkid(self, mocker): gdf_mock = mocker.patch("palletjack.utils.gpd.GeoDataFrame").return_value - df_attrs = {"spatial.sr": {"wkid": "foo"}} - df_mock = mocker.Mock(**df_attrs) + + df_mock = mocker.Mock() + df_mock.spatial.sr = mocker.Mock(spec=palletjack.utils.arcgis.geometry.SpatialReference) + df_mock.spatial.sr.wkid = "foo" palletjack.utils.sedf_to_gdf(df_mock) gdf_mock.set_crs.assert_called_with("foo", inplace=True) def test_sedf_to_gdf_uses_sedf_geometry_column(self, mocker): - mock_sedf = mocker.Mock(**{"spatial.name": "FOOSHAPE", "spatial.sr": {"wkid": "foo"}}) + mock_sedf = mocker.Mock(**{"spatial.name": "FOOSHAPE"}) # , "spatial.sr": {"wkid": "foo"}}) + mock_sedf.spatial.sr = mocker.Mock(spec=palletjack.utils.arcgis.geometry.SpatialReference) + mock_sedf.spatial.sr.wkid = "foo" gpd_mock = mocker.patch("palletjack.utils.gpd.GeoDataFrame") palletjack.utils.sedf_to_gdf(mock_sedf)