Gernerate geospatial shape pairs with prescribed relations
Project description
geo-relations
Generate datasets to test geometric relationships
This package generates datasets to develop and test code quantifying spatial relationships. For example, if you have something that determines whether two lines intersect, then you can create a dataset of thousands of line pairs, some of which intersect and some of which don't, and use that to train and test a model.
The intended use is for models that estimate geometric relationships based on approximate positional encodings. It helps answers questions like, "given approximate encodings for a pair of lines, how well does my model determine whether the lines intersect?"
In order to give the data some geospatial realism, this package pulls shapes of various entities from OpenStreetMap. It then moves and shifts them around to assure that prescribed relationships either do or do not exist between them.
All shapes are returned within a square 2D coordinate system, of a size that you specify, with no defined length units.
Here is a quick example of its use.
from geo_relations import OSMShapeCollector
from geo_relations import RelationGenerator
center_lat, center_lon = 42.631024, -70.993787
extent = 20000.0
collector = OSMShapeCollector(center_lon, center_lat, extent)
shapes = collector.collect(['linestrings', 'polygons'])
generator = RelationGenerator(shapes, bounds=[0, 0, 100, 100], scale=[0.1, 0.25])
a, b = generator.generate('linestring-intersects-polygon', True)
At this point, a and b will be, respectively, a LineString
and a Polygon that intersect one another. Their size will be somewhere
between 10 and 25 units, and they will be placed at a random location
in a coordinate space from (0, 0) lower left to (100, 100) upper right.
The actual shapes will be scaled versions of
entities pulled from a 20km box centered
on the given lon/lat location.
If you want such a pair of shapes guaranteed NOT to intersect,
call
a, b = generator.generate('linestring-intersects-polygon', False)
At this time, the types of relationships that can be generated are:
point-on-linestringpoint-in-polygonlinestring-intersects-linestringlinestring-intersects-polygonpolygon-intersects-polygonpolygon-borders-polygon
Examples
This package generates pairs that look something like this.
Supporting packages
geopandas: Supports data frames containing geometric objects.shapely: Provides computations on geometric objects.osmnx: Used to pull shapes from OpenStreetMap. See: Boeing, G. (2024). Modeling and Analyzing Urban Networks and Amenities with OSMnx. Working paper. https://geoffboeing.com/publications/osmnx-paper/
Installation
pip install geo-relations
Author and maintainers
- John Collins --
john@odyssey-geospatial.com
Contributing
- Fork the repo (https://github.com/yourname/yourproject/fork)
- Create your feature branch (git checkout -b feature/myNewFeature)
- Commit your changes (git commit -am 'Add my new feature')
- Push to the branch (git push origin feature/myNewFeature)
- Create a new Pull Request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geo_relations-1.0.2.tar.gz.
File metadata
- Download URL: geo_relations-1.0.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f8e2ad22aa210b52f0371b64eeac0c99f5ee8bb6fbc6074120323f5985f762c
|
|
| MD5 |
49c2bd95558f00c6d0de92e1bc15e27b
|
|
| BLAKE2b-256 |
9c840616d0e1dd6e1b0dd7cb4e380f5eb26e46daa614458f68231b1d63af3253
|
File details
Details for the file geo_relations-1.0.2-py2.py3-none-any.whl.
File metadata
- Download URL: geo_relations-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2dc3f6d6aa72bfbd8f255a91e339a8a93ad74829efc9c2a24b085f00f253248
|
|
| MD5 |
d800eb916c87092d80bfdd2e0555d662
|
|
| BLAKE2b-256 |
449d7a0a875d6720ce0cba5dc077195621b1f1dcde2f833a742ac4d9b196299c
|