An open source library for processing geospatial data using Python and PostGIS.
Project description
Models API Examples
This repository contains several Jupyter Notebooks that demonstrate the Models API which I wrote for Envelope. The API contains many powerful functions for processing GIS data and is built entirely on open-source libraries.
About the Models API
The Models API is a library for processing GIS data, and was originally designed to mimic functions found in Esri's "Geoprocessing" toolbox (a part of their ModelBuilder product). At the API's inception, Envelope was using Esri-based products to perform geoprocessing, but the company had a long-term goal of transitioning to open-source products that were less expensive and more in line with the company's other technology stacks. The Models API was designed to ease the transition to open-source libraries by creating a conceptual layer between the GIS processing logic and the underlying GIS function calls.
The Models API was originally based on Esri's ArcPy library, but once the API had been used to segregate the application's business logic from the GIS processing functions the application could then be transitioned from ArcPy to open-source libraries with a minimum amount of effort. The Models API is now based entirely on open-source libraries, primarily:
- PostgreSQL and PostGIS
- Python
psycopg2sqlAlchemyandgeoAlchemypandasandgeopandasshapelymatplotlib
About the Examples
This repository contains several examples of how the Models API can be used to process geographic data. The work performed in each example is described below:
The Basics
Geometry Manipulation Example
The Geometry Manipulation Example demonstrates the basics of creating and manipulating geometries using the Models API, as well as some simple examples of comparing geometries spatially. This example only contains a small sample of the wide variety of functions available in the Models API for creating, comparing, and manipulating geometries.
The API's geometry objects (Point(), Line(), and Polygon()) are based primarily on shapely geometry objects, with additional support from matplotlib for plotting geometries in Jupyter Notebooks.
Geodatabase Manipulation Example
The Geodatabase Manipulation Example demonstrates how to use the Models API to connect to and manipulate PostGIS geodatabases. The example includes how to create geodatabases, tables, rows, and columns, as well as a few advanced geoprocessing functions such as identity overlays and dissolve functions. This example contains only a small sample of the many methods available in the Models API to query, manipulate, and compare geographic data between PostGIS datasets.
The API's geodatabase objects (Workspace(), Table(), and Layer()) are designed to work with PostGIS databases and are based primarily on the psycopg2 and geoAlchemy libraries, with some support from geopandas. Internally the API uses PostGIS ST_Geometry functions to create spatial queries for comparing datasets and manipulating data.
Data Migration Example
The Data Migration Example demonstrates how the Models API can be used to perform common migration and transformation tasks on spatial datasets. The example shows how an existing dataset can be filtered (both spatially and by attribute) and reprojected to a new coordinate system. The example also shows how columns can be added, renamed, or dropped using the API.
Case Studies
Bus Stop Distance Example
The Bus Stop Distance Example shows how the Models API can be used to find the distance between geometries in two different datasets. The example modifies a parcels dataset by adding columns to the table and populating the columns with the name of and distance to the nearest bus stop. The bus stop data is stored in a separate dataset and PostGIS functions are used to help compare the data between the tables.
CitiBike JSON Import Example
The CitiBike JSON Import Example demonstrates how the Models API can be used to import JSON into a PostGIS geodatabase. The example creates a new geodatabase to house the imported data, creates a table based on the data found in the JSON file, and loads the table with the JSON data. The data is also projected to a new coordinate system to be consistent with other datasets in our process.
Street Label Points Example
The Street Label Points Example demonstrates how the Models API was used to find the best locations for street labels based on their proximity to city blocks. The example finds the location points for each label and also determines the ideal rotation angle for the text (this was done to help support displaying the labels in reports and other projects).
Subway Stations Example
The Subway Stations Example demonstrates how the Models API can be used to extract data from one dataset and apply it to another based on spatial attributes. The example uses a points dataset containing subway names to associate subway names with polygons in a subway stations polygon dataset. The spatial relationships between the points and polygons are used to determine the names for the station polygons.
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 oogeo-0.0.5.tar.gz.
File metadata
- Download URL: oogeo-0.0.5.tar.gz
- Upload date:
- Size: 121.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
246bfb346015549821b14f15b0cbafd91dbf8ef6497b3ed8142ecfcab1ff8744
|
|
| MD5 |
cdb31b9838ea70c0a34b6454b99b2601
|
|
| BLAKE2b-256 |
976e5d4bfc899fef877d1ce2ce7032ee26628716a41a1c93b51740448addf60f
|
File details
Details for the file oogeo-0.0.5-py3-none-any.whl.
File metadata
- Download URL: oogeo-0.0.5-py3-none-any.whl
- Upload date:
- Size: 130.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2211eb134f369c248b422bd8e426b053612c1e82ae8e144aa9135b3642a67ed4
|
|
| MD5 |
4902c822c0771f1b24608d741a4997c5
|
|
| BLAKE2b-256 |
78f45956b47c1abc09aa74b436cd5524e262e40f8f89a1573cc9084e18b990c8
|