FastGeofeature is a geospatial api to serve features from a mulititude of PostGIS enabled databases. FastGeofeature is written in Python using the FastAPI web framework.
Source Code: https://github.com/mkeller3/FastGeofeature
FastGeofeature requires PostGIS >= 2.4.0.
In order for the api to work you will need to edit the config.py
file with your database connections.
Example
DATABASES = {
"data": {
"host": "localhost", # Hostname of the server
"database": "data", # Name of the database
"username": "postgres", # Name of the user, ideally only SELECT rights
"password": "postgres", # Password of the user
"port": 5432, # Port number for PostgreSQL
}
}
To run the app locally uvicorn main:app --reload
Build Dockerfile into a docker image to deploy to the cloud.
Method | URL | Description |
---|---|---|
GET |
/api/v1/ |
Landing Page |
GET |
/api/v1/conformance |
Conformance |
GET |
/api/v1/collections |
Collections |
GET |
/api/v1/collections/{name} |
Feature Collection |
GET |
/api/v1/collections/{name}/items |
Features |
GET |
/api/v1/collections/{name}/items/{id} |
Feature |
GET |
/api/v1/health_check |
Server health check: returns 200 OK |
Collection endpoint returns a list of all available tables to query.
Collections endpoint is available at /api/v1/collections
curl http://localhost:8000/api/v1/collections
Example Response
[
{
"id": "data.public.zip_centroids",
"title": "zip_centroids",
"description": "zip_centroids",
"keywords": [
"zip_centroids"
],
"links": [
{
"type": "application/json",
"rel": "self",
"title": "This document as JSON",
"href": "http://127.0.0.1:8000/api/v1/collections/data.public.zip_centroids"
}
],
"extent": {
"spatial": {
"bbox": [
-180,
-90,
180,
90
],
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
}
},
"itemType": "feature"
},
{},...
Feature Collection endpoint returns information about a single table.
Collections endpoint is available at /api/v1/collections/{item}
curl http://localhost:8000/api/v1/collections/data.public.zip_centroids
Example Response
{
"id": "data.public.zip_centroids",
"title": "data.public.zip_centroids",
"description": "data.public.zip_centroids",
"keywords": [
"data.public.zip_centroids"
],
"links": [
{
"type": "application/json",
"rel": "self",
"title": "Items as GeoJSON",
"href": "http://127.0.0.1:8000/api/v1/collections/data.public.zip_centroids/items"
}
],
"extent": {
"spatial": {
"bbox": [
-180,
-90,
180,
90
],
"crs": "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
}
},
"itemType": "feature"
}
Features endpoint returns a geojson feature collection for a feature collection.
Collections endpoint is available at /api/v1/collections/{item}/items
curl http://localhost:8000/api/v1/collections/data.public.states/items
bbox=mix,miny,maxx,maxy
- filter features in response to ones intersecting a bounding box (in lon/lat or specified CRS). Ex.17,-48,69,-161
<propname>=val
- filter features for a property having a value. Multiple property filters are ANDed together.filter=cql-expr
- filters features via a CQL expression.properties=PROP-LIST
- return only specific properties (comma-separated). If PROP-LIST is empty, no properties are returned. If not present, all properties are returned.dinates to use N decimal placessortby=PROP[A|D]
- sort the response items by a property (ascending (default) or descending).limit=N
- limits the number of features in the response.offset=N
- starts the response at an offset.srid=srid_number
- The srid number for data. Default is 4326.
Example Response
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
...
]
},
"properties": {
"gid": 5,
"state_name": "Nevada",
"state_fips": "32",
"sub_region": "Mountain",
"state_abbr": "NV",
"population": 2994047
}
},
...
]
}
Feature endpoint returns a geojson feature collection for a single feature in a feature collection.
Collections endpoint is available at /api/v1/collections/{item}/items/{id}
curl http://localhost:8000/api/v1/collections/data.public.states/items/5
properties=PROP-LIST
- return only specific properties (comma-separated). If PROP-LIST is empty, no properties are returned. If not present, all properties are returned.dinates to use N decimal places
Example Response
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
...
]
},
"properties": {
"gid": 5,
"state_name": "Nevada",
"state_fips": "32",
"sub_region": "Mountain",
"state_abbr": "NV",
"population": 2994047
}
}
]
}