-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add method for boolean intersects (#118)
* feat: add method for boolean intersects * docs: update main readme for docs to feature conversion and boolean * ci: update python versions * style: clean up linting * ci: enable testing on all branches * ci: wrap 10 in quotes * test: update for failing test cases * docs: update for doc underline * docs: title length * docs: add whitespace * docs: update characters used in docs * docs: updates for buildign docs * ci: update python versions * build: require geopandas * fix: importing geopandas directly * fix: change package versions * ci: updated yml file for running actions
- Loading branch information
Showing
125 changed files
with
4,174 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Boolean Examples : | ||
* boolean_disjoint : Takes two features and returns (TRUE) if the two geometries do not touch or overlap. | ||
|
||
| Argument| Type | Description| | ||
| ------- |------ | ----------- | | ||
| `feature_1` |Feature | Feature 1 | | ||
| `feature_2` |Feature | Feature 2 | | ||
|
||
|
||
| Return | Type | Description | | ||
| ------- | ------ | ----------- | | ||
| `bool` | bool | Return true or false | | ||
|
||
```python | ||
from geojson import Feature, Point | ||
from turfpy.boolean import boolean_disjoint | ||
|
||
feature_1 = Feature(geometry=Point((19.0760, 72.8777))) | ||
feature_2 = Feature(geometry=Point((29.0760, 72.8777))) | ||
boolean_disjoint(feature_1, feature_2) | ||
``` | ||
|
||
* boolean_intersects : Takes two features and returns (TRUE) if the intersection of the two geometries is NOT an empty set. | ||
|
||
| Argument| Type | Description| | ||
| ------- |------ | ----------- | | ||
| `feature_1` |Feature | Feature 1 | | ||
| `feature_2` |Feature | Feature 2 | | ||
|
||
| Return | Type | Description | | ||
| ------- | ------ | ----------- | | ||
| `bool` | bool | Return true or false | | ||
|
||
```python | ||
from geojson import Feature, Point | ||
from turfpy.boolean import boolean_intersects | ||
|
||
feature_1 = Feature(geometry=Point((19.0760, 72.8777))) | ||
feature_2 = Feature(geometry=Point((29.0760, 72.8777))) | ||
boolean_intersects(feature_1, feature_2) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
#test | ||
pytest | ||
mypy | ||
coverage | ||
black | ||
mypy | ||
pytest-cov | ||
pytest-mypy | ||
pytest-flake8 | ||
isort | ||
Sphinx>=2.4.0 | ||
sphinx-rtd-theme | ||
jupyter-sphinx==0.2.4a1 | ||
ipyleaflet | ||
# optional dependencies required for line_intersect | ||
geopandas | ||
pygeos | ||
pytest==8.3.3 | ||
mypy==1.13.0 | ||
coverage==7.6.4 | ||
black==24.10.0 | ||
pytest-cov==6.0.0 | ||
pytest-mypy==0.10.3 | ||
pytest-flake8==1.2.2 | ||
isort==5.13.2 | ||
Sphinx==8.1.3 | ||
sphinx-rtd-theme==3.0.1 | ||
jupyter-sphinx==0.5.3 | ||
ipyleaflet==0.19.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Boolean Disjoint | ||
================= | ||
Takes two features and returns (TRUE) if the two geometries do not touch or overlap. | ||
|
||
Example | ||
------- | ||
|
||
.. jupyter-execute:: | ||
|
||
from geojson import Feature, Point | ||
from turfpy.boolean import boolean_disjoint | ||
|
||
feature_1 = Feature(geometry=Point((19.0760, 72.8777))) | ||
feature_2 = Feature(geometry=Point((29.0760, 72.8777))) | ||
boolean_disjoint(feature_1, feature_2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Boolean Intersects | ||
================== | ||
Takes two features and returns (TRUE) if the intersection of the two geometries is NOT an empty set. | ||
|
||
Example | ||
------- | ||
|
||
.. jupyter-execute:: | ||
|
||
from geojson import Feature, Point | ||
from turfpy.boolean import boolean_intersects | ||
|
||
feature_1 = Feature(geometry=Point((19.0760, 72.8777))) | ||
feature_2 = Feature(geometry=Point((29.0760, 72.8777))) | ||
boolean_intersects(feature_1, feature_2) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Polygon to Line | ||
================ | ||
Takes a Polygon or MultiPolygon and convert it to a line. | ||
|
||
Example | ||
------- | ||
|
||
.. jupyter-execute:: | ||
|
||
from geojson import Feature, Polygon | ||
from turfpy.feature_conversion import polygon_to_line | ||
|
||
feature_1 = Feature(geometry=Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]])) | ||
polygon_to_line(feature_1) | ||
|
||
Interactive Example | ||
------------------- | ||
|
||
.. jupyter-execute:: | ||
|
||
from turfpy.feature_conversion import polygon_to_line | ||
from geojson import Polygon | ||
from geojson import Feature | ||
from ipyleaflet import Map, WidgetControl | ||
from ipywidgets import HTML | ||
|
||
feature_1 = Feature(geometry=Polygon([[(2.38, 57.322), (23.194, -20.28), (-120.43, 19.15), (2.38, 57.322)]])) | ||
|
||
geo_json = polygon_to_line(feature_1) | ||
|
||
m = Map(center=[20.04303061200023, -11.832275390625002], zoom=2) | ||
|
||
m.add_layer(geo_json) | ||
|
||
html = HTML() | ||
html.layout.margin = "0px 20px 10px 20px" | ||
html.value = """ | ||
<h4>Polygon to Line for given geojson</h4> | ||
<h4>{}</h4> | ||
""".format( | ||
geo_json | ||
) | ||
control = WidgetControl(widget=html, position="topright") | ||
m.add_control(control) | ||
|
||
m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
turfpy.boolean module | ||
========================= | ||
|
||
.. automodule:: turfpy.boolean | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
turfpy.turfpy.feature_conversion module | ||
========================= | ||
|
||
.. automodule:: turfpy.turfpy.feature_conversion | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
turfpy.random module | ||
==================== | ||
|
||
.. automodule:: turfpy.random | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Boolean\n", | ||
"This notebook demonstrates all the examples of boolean" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Boolean Disjoint\n", | ||
"Takes two features and returns (TRUE) if the two geometries do not touch or overlap." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from geojson import Feature, Point\n", | ||
"from turfpy.boolean import boolean_disjoint\n", | ||
"\n", | ||
"feature_1 = Feature(geometry=Point((19.0760, 72.8777)))\n", | ||
"feature_2 = Feature(geometry=Point((29.0760, 72.8777)))\n", | ||
"boolean_disjoint(feature_1, feature_2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Boolean Intersects\n", | ||
"Takes two features and returns (TRUE) if the intersection of the two geometries is NOT an empty set." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from geojson import Feature, Point\n", | ||
"from turfpy.boolean import boolean_intersects\n", | ||
"\n", | ||
"feature_1 = Feature(geometry=Point((19.0760, 72.8777)))\n", | ||
"feature_2 = Feature(geometry=Point((29.0760, 72.8777)))\n", | ||
"boolean_intersects(feature_1, feature_2)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.