Skip to content

Commit

Permalink
Merge pull request #164 from SpatioTemporal/fix-geopandas-vectorized-…
Browse files Browse the repository at this point in the history
…issue

Fix vectorized package issue in the new version of geopandas and add a troubleshooting to README.md
  • Loading branch information
TonHai1111 authored Aug 23, 2024
2 parents b245235 + 0b3f9db commit 718ac62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ stare_amazon = samerica.stare_intersection(amazon.make_sids.iloc[0])
![Example 3](figures/amazon.png)
# Troubleshooting
## `UserWarning: pyproj unable to set database path _pyproj_global_context_initialize()` Or `Invalid projection: EPSG:4326: (Internal Proj Error: proj_create: no database context specified)`
This is typically caused by a problem with the PROJ library and Geopandas. So, one potential solution for this is to do the followings:
- Install proj-data with conda: `conda install -c conda-forge proj-data`
- Install geopandas and pyproj with pip:
- may need to uninstall geopandas from conda: `conda remove geopandas`
- `pip install scipy`
- `pip install pyproj geopandas`
- May need to install shapely with conda: `conda install -c conda-forge shapely`
- May need to intall matlib: `conda install -c conda-forge matplotlib`
- Check the PROJ data directory:
- `import python`
- `print(pyproj.datadir.get_data_dir())`
- `export PROJ_LIB=/path/to/proj/data`
# Acknowledgments
2018-2021 STARE development supported by NASA/ACCESS-17 grant 80NSSC18M0118.
Expand Down
6 changes: 3 additions & 3 deletions starepandas/tools/trixel_conversions.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import math

import dask.dataframe
import geopandas._vectorized as vectorized
import numpy
import pystare
import shapely
import geopandas
from shapely.geometry import Point
from geopandas.array import from_shapely


def to_vertices(sids, wrap_lon=True):
Expand Down Expand Up @@ -545,7 +545,7 @@ def trixels_from_stareseries(sids_series, n_partitions=1, num_workers=None, wrap
ddf = dask.dataframe.from_pandas(sids_series, npartitions=npartitions)
meta = {'name': 'geometry'}
res = ddf.map_partitions(lambda df:
vectorized.from_shapely(
from_shapely(
trixels_from_stareseries(df, n_partitions=1, wrap_lon=wrap_lon)).flatten(),
meta=meta)
trixels_series = res.compute(scheduler='processes', num_workers=num_workers)
Expand Down Expand Up @@ -579,7 +579,7 @@ def split_antimeridian_series(trixels_series, n_partitions=1, num_workers=None,
ddf = dask.dataframe.from_pandas(trixels_series, npartitions=n_partitions)
meta = {'trixels': 'object'}
res = ddf.map_partitions(lambda df:
vectorized.from_shapely(
from_shapely(
split_antimeridian_series(df, n_partitions=1, drop=drop)).flatten(),
meta=meta)
trixels_series = res.compute(scheduler='processes', num_workers=num_workers)
Expand Down

0 comments on commit 718ac62

Please sign in to comment.