Miscellaneous#
Get resource data#
Geodatata can be fetched for vector and raster layers. For vector layers (PostGIS and Vector) geodata returns in GeoJSON or CSV formats. For raster layers (Raster, WMS) - tiles (TMS) or image. For QGIS styles - qml file.
Export vector layer as file#
The following request returns GPKG, GeoJSON or CSV file from vector layer:
- GET /api/resource/(int: id)/export?format=GPKG&srs=4326&zipped=True&fid=ngw_id&encoding=UTF-8#
Example request: https://sandbox.nextgis.com/api/resource/4308/export?format=GPKG&srs=4326&zipped=False&fid=ngw_id&encoding=UTF-8
Format string is case-sensitive. For formats and options list see https://docs.nextgis.ru/docs_ngcom/source/data_export.html
GeoJSON#
The following request returns GeoJSON file from vector layer:
Added in version 3.0.
- GET /api/resource/(int: id)/geojson#
GeoJSON file request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Parameters:
id – resource identifier
- Status Codes:
200 OK – no error
Example request:
GET /api/resource/55/geojson HTTP/1.1
Host: ngw_url
Accept: */*
CSV#
The following request returns CSV file from vector layer:
Added in version 3.0.
- GET /api/resource/(int: id)/csv#
CSV file request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Parameters:
id – resource identifier
- Status Codes:
200 OK – no error
Example request:
GET /api/resource/55/csv HTTP/1.1
Host: ngw_url
Accept: */*
Render#
The following request returns TMS from raster layer:
Added in version 3.0.
- GET /api/component/render/tile?z=(int: z)&x=(int: x)&y=(int: y)&resource=(int: id1),(int: id2)...#
Tile request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Query Parameters:
id2 (id1,) – style resources id’s
z – zoom level
x – tile number on x axis (horizontal)
y – tile number on y axis (vertical)
cache – optional parameter (defaults true). If value set false tile will render from scratch
nd – Return code if tile not present. Available values are: 204, 404, 200. Defaults to 200.
- Status Codes:
200 OK – no error
204 No Content – no tile
404 Not Found – no tile
The following request returns image from raster layer:
Added in version 3.0.
- GET /api/component/render/image?extent=(float: minx),(float: miny),(float: maxx),(float: maxy)&size=(int: width),(int: height)&resource=(int: id1),(int: id2)...#
Image request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Query Parameters:
id2 (id1,) – style resources id’s
maxy (minx, miny, maxx,) – image spatial extent
height (width,) – output image size
cache – optional parameter (defaults true). If value set false tile will render from scratch
- Status Codes:
200 OK – no error
Note
Styles order should be from lower to upper.
Example request:
GET /api/component/render/tile?z=7&x=84&y=42&resource=234 HTTP/1.1
Host: ngw_url
Accept: */*
QML Style (QGIS Layer style)#
The following request returns QML from QGIS style:
Added in version 3.0.1.
- GET /api/resource/(int: id)/qml#
QML file request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Parameters:
id – resource identifier
- Status Codes:
200 OK – no error
Example request:
GET /api/resource/56/qml HTTP/1.1
Host: ngw_url
Accept: */*
MVT (vector tiles)#
MVT data can be fetched only for NextGIS Web vector layer.
The following request returns MVT data:
Added in version 3.0.4.
- GET /api/component/feature_layer/mvt?x=(int: x)&y=(int: y)&z=(int: z)&resource=(int: id1),(int: id2)...&simplification=(int: s)#
Vector tile request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Query Parameters:
id2 (id1,) – Vector or PostGIS layers identifies
z – zoom level
x – tile number on x axis (horizontal)
y – tile number on y axis (vertical)
s – simplification level (0 - no simplification, 8 - default value)
- Status Codes:
200 OK – no error
Note
Vector or PostGIS layers identifies order should be from lower to upper.
Layers names in MVT will be ngw:(int:id), where id is vector or PostGIS layer identifier.
Example request:
GET /api/component/feature_layer/mvt?resource=56&z=11&x=1234&y=543 HTTP/1.1
Host: ngw_url
Accept: */*
Deprecated since version 3.0.4.
- GET /api/resource/(int: id)/(int: z)/(int: x)/(int: y).mvt#
MVT request
- Deprecated:
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Parameters:
id – resource identifier
z – zoom level
x – x tile column
y – y tile row
- Status Codes:
200 OK – no error
Example request:
GET /api/resource/56/11/1234/543.mvt HTTP/1.1
Host: ngw_url
Accept: */*
Identify by polygon#
To get features intersected by a polygon execute following request.
- POST /api/feature_layer/identify#
Identification request
- Request Headers:
Accept – must be
*/*Authorization – optional Basic auth string to authenticate
- Request JSON Object:
srs (int) – Spatial reference identifier
geom (string) – Polygon in WKT format
- Request JSON Array of Objects:
layers (int) – layers id array
- Status Codes:
200 OK – no error
Example request:
POST /api/feature_layer/identify HTTP/1.1
Host: ngw_url
Accept: */*
{
"srs":3857,
"geom":"POLYGON((4188625.8318882 7511123.3382522,4188683.1596594 7511123.
3382522,4188683.1596594 7511180.6660234,4188625.8318882
7511180.6660234,4188625.8318882 7511123.3382522))",
"layers":[2,5]
}
Example response:
{
"2": {
"featureCount": 1,
"features": [
{
"fields": {
"Id": 25,
"name": "Church 1514-1925"
},
"id": 3,
"label": "#3",
"layerId": 2
}
]
},
"5": {
"featureCount": 0,
"features": []
},
"featureCount": 1
}