Features
/features
List Features
URL: /layers/{layer_id}/features
Method: GET
Protocol: HTTP, HTTPS
Parameters:
- layer_id – layer id
- [optional] geometry – value: geojson, wkt, kml, gml – format in which geometry will be packed
- [optional] epsg – EPSG code for the output projection. if not specified default map projection is used.
- [optional] proj4 – Proj4 string for the output projection. Alternative to the epsg parameter
- [optional] bounds – value:,,, – bounding box used for spatial filtering
- [optional] where – SQL type where clause – used for attribute filtering
Returns:
- 200 (OK) + a collection of features
Example:
$ curl -X GET http://api.giscloud.com/1/maps/895/layers/3823/features.xml?geometry=wkt&epsg=4326&bounds=-73.4765,41.8940,-73.081,42.0492&where=pop2003>4700 <features total="2" page="1"> <feature> <__id>889</__id> <__modified/> <__created/> <__owner/> <__ymax>41.966291</__ymax> <__ymin>41.909464</__ymin> <__xmax>-73.033991</__xmax> <__xmin>-73.121582</__xmin> <__geometry> POLYGON ((-73.097481818181819 41.934690909090904,-73.097454545454539 41.934672727272719,...,-73.097481818181819 41.934690909090904)) </__geometry> <data> <age_22_29>524</age_22_29> <hsehld_1_f>502</hsehld_1_f> ... <pop2003>6101</pop2003> <owner_occ>1398</owner_occ> </data> </feature> ... </features>
Get Feature
URL: /layers/{layer_id}/features/{id}
Method: GET
Protocol: HTTP, HTTPS
Parameters:
- id – feature to be retrieved
- layer_id – layer id
Example:
$curl -X GET http://api.giscloud.com/1/layers/2/features/0 <feature> <__id>1</__id> <__ymax>-1273227.350838</__ymax> <__ymin>-1338968.388324</__ymin> <__xmax>4842861.164380</__xmax> <__xmin>4810759.738498</__xmin> <data> <pop_density>261.033720</pop_density> <sr>-99.990000</sr> <p90>270330</p90> <p80>182656</p80> <p70>136366</p70> <p60>91128</p60> <demoflag>1</demoflag> <name3>N.A.</name3> <name2>N.A.</name2> <name1>Grand Comore</name1> <country>COM</country> <adminid>174010000</adminid> <code>IS</code> <admsqkm>1035.600000</admsqkm> <sqkm>1035.600000</sqkm> <afall_id>3267</afall_id> <afall_>4469</afall_> <perimeter>1.498000</perimeter> <area>0.086000</area> </data> </feature>
Create Feature
URL: /layers/{layer_id}/features
Method: POST
Protocol: HTTPS
Returns:
- 201 (Created) + a URL to the newly created resource in the Location header of the response
Example:
$ curl -X POST https://api.giscloud.com/1/layers/11/features
Adding feature on the map on latlong coordinates (15, 45).
$ curl -H "Content-Type: application/json" -X POST -d '{"data": {"a": "myname", "b": 995}, "geometry": "POINT(15 45)"}' "https://api.giscloud.com/1/layers/<LAYER_ID>/features.json?api_key=<API_KEY>" -v
When creating or updating a feature, you can specify the geometry in the geometry field, in WKT (Well-Known Text) format.
<?xml version="1.0"?> <geometry>POINT(1.2514532 28.1233253)</geometry> <data> <p90>270330</p90> <pop_density>261.033720</pop_density> ... </data>
Update Feature
URL: /layers/{layer_id}/features/{id}
Method: PUT
Protocol: HTTPS
Returns one of:
- 204 if successful
- 404 if the resource wasn’t found
Example:
curl -H "Content-Type: application/json" -X PUT -d '{"data": {"media": "<FILE_NAME>"}}' "https://editor.giscloud.com/1/layers/<LAYER_ID>/features/<FEATURE_ID>.json?api_key=<API_KEY>" -v
Delete Feature
URL: /layers/{layer_id}/features/{id}
Method: DELETE
Protocol: HTTPS
Returns one of:
- 204 if successful
- 404 if the resource wasn’t found
Feature Media File
URL: /layers/{layer_id}/features/{id}/{field_name}/{file_name}[?download]
Method: GET
Protocol: HTTP(S)
Parameters:
- id – feature holding the media files
- field_name – name of the attribute which contains media files; separate multiple files with commas
- file_name – media file name
- download – force browser to download the file like an attachment
Returns one of:
- 200 and the requested file
- 404 (Not Found) if the resource wasn’t found