Skip to content

Commit

Permalink
Merge pull request #172 from martinfleis/shapely2
Browse files Browse the repository at this point in the history
  • Loading branch information
knaaptime authored Apr 11, 2023
2 parents d245ec1 + c412a8d commit 97205be
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 19 deletions.
1 change: 0 additions & 1 deletion .ci/37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- pytest-cov
- twine
- pip
- pygeos
- h3-py
- joblib
- astropy
1 change: 0 additions & 1 deletion .ci/38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ dependencies:
- pytest-cov
- twine
- pip
- pygeos
- h3-py
- joblib
- astropy
1 change: 0 additions & 1 deletion .ci/39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
- pytest-cov
- twine
- pip
- pygeos
- h3-py
- mapclassify
- descartes
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# PySAL `tobler`

`tobler` is a python package for areal interpolation, dasymetric mapping, change of support, and small area estimation. It provides a suite of tools with a simple interface for transferring data from one polygonal representation to another. Common examples include standardizing census data from different time periods to a single representation (i.e. to overcome boundary changes in successive years), or the conversion of data collected at different spatial scales into shared units of analysis (e.g. converting zip code and neighborhood data into a regular grid). `tobler` is part of the [PySAL](https://pysal.org) family of packages for spatial data science and provides highly performant implementations of basic and advanced interpolation methods, leveraging [`pygeos`](https://pygeos.readthedocs.io/en/latest/) to optimize for multicore architecture. The package name is an homage to the legendary quantitative geographer [Waldo Tobler](https://en.wikipedia.org/wiki/Waldo_R._Tobler), a pioneer in geographic interpolation methods, spatial analysis, and computational social science.
`tobler` is a python package for areal interpolation, dasymetric mapping, change of support, and small area estimation. It provides a suite of tools with a simple interface for transferring data from one polygonal representation to another. Common examples include standardizing census data from different time periods to a single representation (i.e. to overcome boundary changes in successive years), or the conversion of data collected at different spatial scales into shared units of analysis (e.g. converting zip code and neighborhood data into a regular grid). `tobler` is part of the [PySAL](https://pysal.org) family of packages for spatial data science and provides highly performant implementations of basic and advanced interpolation methods, leveraging [`shapely`](https://shapely.readthedocs.io/en/latest/) to optimize for multicore architecture. The package name is an homage to the legendary quantitative geographer [Waldo Tobler](https://en.wikipedia.org/wiki/Waldo_R._Tobler), a pioneer in geographic interpolation methods, spatial analysis, and computational social science.

![DC tracts to hexgrid](docs/_static/images/notebooks_census_to_hexgrid_25_1.png)

Expand Down Expand Up @@ -49,7 +49,7 @@ Model-based interpolation uses [spatial] statistical models to estimate a relati

```bash
$ conda env create -f environment.yml
$ conda activate tobler
$ conda activate tobler
$ python setup.py develop
```

Expand All @@ -65,7 +65,7 @@ The project is licensed under the [BSD license](https://github.com/pysal/tobler/

## Funding

<img src="docs/figs/nsf_logo.jpg" width="50">
<img src="docs/figs/nsf_logo.jpg" width="50">

Award #1733705 [Neighborhoods in Space-Time Contexts](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1733705&HistoricalAwards=false)

Expand Down
1 change: 1 addition & 0 deletions docs/notebooks/area_interpolate_perf.ipynb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ dependencies:
- libpysal
- tqdm
- pip
- pygeos
- mapclassify
- mapclassify
- descartes
- joblib
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ statsmodels
rasterstats
libpysal
tqdm
pygeos
joblib
joblib
12 changes: 3 additions & 9 deletions tobler/area_weighted/area_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ def _chunk_polys(id_pairs, geoms_left, geoms_right, n_jobs):
chunk_size = id_pairs.shape[0] // n_jobs + 1
for i in range(n_jobs):
start = i * chunk_size
chunk1 = geoms_left.values.data[id_pairs[start : start + chunk_size, 0]]
chunk2 = geoms_right.values.data[id_pairs[start : start + chunk_size, 1]]
chunk1 = geoms_left.array[id_pairs[start : start + chunk_size, 0]]
chunk2 = geoms_right.array[id_pairs[start : start + chunk_size, 1]]
yield chunk1, chunk2


def _intersect_area_on_chunk(geoms1, geoms2):
import pygeos

areas = pygeos.area(pygeos.intersection(geoms1, geoms2))
areas = geoms1.intersection(geoms2).area
return areas


Expand Down Expand Up @@ -249,8 +247,6 @@ def _area_interpolate_binning(
[Optional. Default=1] Number of processes to run in parallel to
generate the area allocation. If -1, this is set to the number of CPUs
available. If `table` is passed, this is ignored.
NOTE: as of Jan'21 multi-core functionality requires master versions
of `pygeos` and `geopandas`.
categorical_variables : list
[Optional. Default=None] Columns in dataframes for categorical variables
Expand Down Expand Up @@ -308,7 +304,6 @@ def _area_interpolate_binning(
dfs = []
extensive = []
if extensive_variables:

den = source_df.area.values
if allocate_total:
den = np.asarray(table.sum(axis=1))
Expand All @@ -332,7 +327,6 @@ def _area_interpolate_binning(

intensive = []
if intensive_variables:

area = np.asarray(table.sum(axis=0))
den = 1.0 / (area + (area == 0))
n, k = den.shape
Expand Down

0 comments on commit 97205be

Please sign in to comment.