{"__v":0,"_id":"54ef62bfa7306e19003f1f99","category":{"__v":7,"_id":"54fdad6e660db63700c23b82","pages":["55fbef82af72eb0d0007df93","55fbf623e013770d008fcba8","5617bd3a26e3db230054fba4","5617c4a6f8c9632100ac74f5","561ed6fd0a04340d00d8a0b0","562156adf4e0352100cbf268","562a5c846049f20d0032520b"],"project":"54d0fd1d095c470d00d1646d","version":"54d0fd1e095c470d00d16470","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-09T14:25:50.133Z","from_sync":false,"order":2,"slug":"api-reference","title":"API Reference"},"editedParams":true,"editedParams2":true,"project":"54d0fd1d095c470d00d1646d","user":"54db646008ea010d00ab1fe1","version":{"__v":20,"_id":"54d0fd1e095c470d00d16470","project":"54d0fd1d095c470d00d1646d","createdAt":"2015-02-03T16:53:50.090Z","releaseDate":"2015-02-03T16:53:50.090Z","categories":["54d0fd1e095c470d00d16471","54d8b5e68934140d00496544","54db6361c6a4d40d0034b8f7","54db638208ea010d00ab1fdd","54db639008ea010d00ab1fde","54db6547c6a4d40d0034b8fd","54db83482092743700ea6ee1","54db84afc6a4d40d0034b93c","54db8805c6a4d40d0034b93f","54db8de9c6a4d40d0034b961","54db931ac6a4d40d0034b96d","54e49219e4365521006fd9ee","54e74fcc652d7c1900cbe737","54e74ffd3c1e111700d05762","54e77e0a523b1b2f00e6f313","54e784affdabe62500fcddcf","54e784fa523b1b2f00e6f319","54e785de8ae8911900cd42c5","54fdad6e660db63700c23b82","54fdff31f7b1202100a25e06"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-02-26T18:15:27.162Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"name":"","code":"{\n  \"buckets_qtd\": 6,\n  \"doc_total\": 55,\n  \"buckets\": [\n    {\n      \"doc_count\": 31,\n      \"key\": \"Computer Services\"\n    },\n    {\n      \"doc_count\": 8,\n      \"key\": \"Management & Consulting\"\n    },\n    {\n      \"doc_count\": 8,\n      \"key\": \"Research\"\n    },\n    {\n      \"doc_count\": 4,\n      \"key\": \"Advertising\"\n    },\n    {\n      \"doc_count\": 2,\n      \"key\": \"Business Services\"\n    },\n    {\n      \"doc_count\": 2,\n      \"key\": \"Electronics\"\n    }\n  ]\n}","language":"json","status":200}]},"settings":"","auth":"required","params":[{"_id":"54db87872092743700ea6eee","ref":"","in":"path","required":true,"desc":"Database name.","default":"","type":"string","name":"database_name"},{"_id":"54db87872092743700ea6eed","ref":"","in":"path","required":true,"desc":"Collection name.","default":"","type":"string","name":"collection_name"},{"_id":"54db87872092743700ea6eec","ref":"","in":"body","required":true,"desc":"Your mapkey.","default":"","type":"string","name":"mapkey"},{"_id":"54db87872092743700ea6eeb","ref":"","in":"body","required":true,"desc":"Field to aggregate the results.","default":"","type":"string","name":"field"},{"_id":"54db87872092743700ea6eea","ref":"","in":"body","required":false,"desc":"Spatial restriction on GeoJSON format (types supported: Point, LineString or Polygon).","default":"","type":"object","name":"geom"},{"_id":"54db87872092743700ea6ee9","ref":"","in":"body","required":false,"desc":"Spatial restriction on JSON format.","default":"","type":"object","name":"points"},{"_id":"54db87872092743700ea6ee8","ref":"","in":"body","required":false,"desc":"Limit the result size.","default":"","type":"int","name":"agg_size"}],"url":"/geoagg/:database_name/:collection_name"},"isReference":false,"order":42,"body":"### Sample Request using *geom* parameter as spatial restriction\n\nThe GeoAggregation **geom** parameter must be specified in the [GeoJSON](http://geojson.org/geojson-spec.html){:target=\"_blank\"} format. You can use the tool [**geojson.io**](http://geojson.io){:target=\"_blank\"} to draw spatial restrictions using this format. Only *Point*, *LineString* or *Polygon* types can be used as relational filters.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -k -H \\\"Content-Type: application/json\\\" -XPOST \\\"https://api.gogeo.io/1.0/geoagg/my_database/my_collection\\\" -d '\\n{\\n  \\\"mapkey\\\": \\\"MAP-KEY\\\",\\n  \\\"field\\\": \\\"subcategory\\\",\\n  \\\"geom\\\": {\\n    \\\"type\\\": \\\"Polygon\\\",\\n    \\\"coordinates\\\": [\\n      [\\n        [\\n          -93.07617187499999,\\n          28.613459424004414\\n        ],\\n        [\\n          -93.07617187499999,\\n          47.57652571374621\\n        ],\\n        [\\n          -66.70898437499999,\\n          47.57652571374621\\n        ],\\n        [\\n          -66.70898437499999,\\n          28.613459424004414\\n        ],\\n        [\\n          -93.07617187499999,\\n          28.613459424004414\\n        ]\\n      ]\\n    ]\\n  }\\n}'\\n\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n### Sample Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"buckets_qtd\\\": 6,\\n  \\\"doc_total\\\": 55,\\n  \\\"buckets\\\": [\\n    {\\n      \\\"doc_count\\\": 31,\\n      \\\"key\\\": \\\"Computer Services\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 8,\\n      \\\"key\\\": \\\"Management & Consulting\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 8,\\n      \\\"key\\\": \\\"Research\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 4,\\n      \\\"key\\\": \\\"Advertising\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 2,\\n      \\\"key\\\": \\\"Business Services\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 2,\\n      \\\"key\\\": \\\"Electronics\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n### Sample Request using *points* parameter as spatial restriction\n\nThe **points** parameter must be specified using the fields *top_right/bottom_left* or *top_left/bottom_right* to limit the bounds of the query.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -k -H \\\"Content-Type: application/json\\\" -XPOST \\\"https://api.gogeo.io/1.0/geoagg/my_database/my_collection\\\" -d '\\n{\\n  \\\"mapkey\\\": \\\"MAP-KEY\\\",\\n  \\\"field\\\": \\\"subcategory\\\",\\n  \\\"points\\\": {\\n    \\\"top_left\\\": [\\n      -93.07617187499999,\\n      47.57652571374621\\n    ],\\n    \\\"bottom_right\\\": [\\n      -66.70898437499999,\\n      28.613459424004414\\n    ]\\n  }\\n}'\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n### Sample Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"buckets_qtd\\\": 6,\\n  \\\"doc_total\\\": 55,\\n  \\\"buckets\\\": [\\n    {\\n      \\\"doc_count\\\": 31,\\n      \\\"key\\\": \\\"Computer Services\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 8,\\n      \\\"key\\\": \\\"Management & Consulting\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 8,\\n      \\\"key\\\": \\\"Research\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 4,\\n      \\\"key\\\": \\\"Advertising\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 2,\\n      \\\"key\\\": \\\"Business Services\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 2,\\n      \\\"key\\\": \\\"Electronics\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n### Sample Request using *agg_size* to limit the result size\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -k -H \\\"Content-Type: application/json\\\" -XPOST \\\"https://api.gogeo.io/1.0/geoagg/my_database/my_collection\\\" -d '\\n{\\n  \\\"mapkey\\\": \\\"MAP-KEY\\\",\\n  \\\"field\\\": \\\"type\\\",\\n  \\\"points\\\": {\\n    \\\"top_right\\\": [\\n      -166.81640625,\\n      73.72659470212253\\n    ],\\n    \\\"bottom_left\\\": [\\n      -49.92187499999999,\\n      26.27371402440643\\n    ]\\n  },\\n  \\\"agg_size\\\": 5\\n}'\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n### Sample Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"doc_total\\\": 189,\\n  \\\"buckets_qtd\\\": 5,\\n  \\\"buckets\\\": [\\n    {\\n      \\\"doc_count\\\": 146,\\n      \\\"key\\\": \\\"Services\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 17,\\n      \\\"key\\\": \\\"Retail Goods\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 16,\\n      \\\"key\\\": \\\"Manufacturing & Wholesale Goods\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 5,\\n      \\\"key\\\": \\\"Food & Drink\\\"\\n    },\\n    {\\n      \\\"doc_count\\\": 5,\\n      \\\"key\\\": \\\"Public Place\\\"\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:html]\n{\n  \"html\": \"<div class=\\\"panel panel-info teste\\\" >\\n  <div class=\\\"panel-body\\\">\\n    This endpoint requires a MAP key. See <a href=\\\"basic-auth\\\">Basic Authentication</a> for more information about the goGeo authentication system.\\n    <br><br>\\n    If you don't have an access key yet, <a href=\\\"https://console.gogeo.io/signup\\\">sign up</a> and grab yours!\\n  </div>\\n</div>\"\n}\n[/block]\n---\n[block:html]\n{\n  \"html\": \"<div class='div-middle'> \\n  <a href='#'>\\n    Top page &spades; </div>\\n  </a>\\n</div>\\n\\n<div class='div-back'> \\n  <a href='/v1.0/docs/geo-aggregation'>\\n    &laquo; Back \\n  </a>\\n</div>\\n\\n<style>\\n\\t.div-back {\\n  \\tpadding-left: 15px;\\n\\t\\tmargin-top: -20px;\\n  }\\n  \\n  .div-middle {\\n  \\ttext-align: center;\\n\\t\\tmargin-top: -15px;\\n  }\\n  \\n  .div-forward {\\n  \\tfloat: right;\\n    padding-right: 15px;\\n\\t\\tmargin-top: -20px;\\n  }\\n</style>\"\n}\n[/block]","excerpt":"GeoAggregation consists to **group** spatial data by an relational attribute. For example, suppose we have a collection with about 700,000 companies in Florida, and we which to determine what companies kind are saturated and what companies kind has deficiencies in Florida. To do this analysis an possible first step is to segment the companies by their categories.","slug":"geoaggdatabase_namecollection_name","type":"post","title":"GeoAggregation query"}

postGeoAggregation query

GeoAggregation consists to **group** spatial data by an relational attribute. For example, suppose we have a collection with about 700,000 companies in Florida, and we which to determine what companies kind are saturated and what companies kind has deficiencies in Florida. To do this analysis an possible first step is to segment the companies by their categories.

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

database_name:
required
string
Database name.
collection_name:
required
string
Collection name.

Body Params

mapkey:
required
string
Your mapkey.
field:
required
string
Field to aggregate the results.
geom:
object
Spatial restriction on GeoJSON format (types supported: Point, LineString or Polygon).
points:
object
Spatial restriction on JSON format.
agg_size:
integer
Limit the result size.

Result Format


Documentation

### Sample Request using *geom* parameter as spatial restriction The GeoAggregation **geom** parameter must be specified in the [GeoJSON](http://geojson.org/geojson-spec.html){:target="_blank"} format. You can use the tool [**geojson.io**](http://geojson.io){:target="_blank"} to draw spatial restrictions using this format. Only *Point*, *LineString* or *Polygon* types can be used as relational filters. [block:code] { "codes": [ { "code": "curl -k -H \"Content-Type: application/json\" -XPOST \"https://api.gogeo.io/1.0/geoagg/my_database/my_collection\" -d '\n{\n \"mapkey\": \"MAP-KEY\",\n \"field\": \"subcategory\",\n \"geom\": {\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [\n -93.07617187499999,\n 28.613459424004414\n ],\n [\n -93.07617187499999,\n 47.57652571374621\n ],\n [\n -66.70898437499999,\n 47.57652571374621\n ],\n [\n -66.70898437499999,\n 28.613459424004414\n ],\n [\n -93.07617187499999,\n 28.613459424004414\n ]\n ]\n ]\n }\n}'\n", "language": "json" } ] } [/block] ### Sample Response [block:code] { "codes": [ { "code": "{\n \"buckets_qtd\": 6,\n \"doc_total\": 55,\n \"buckets\": [\n {\n \"doc_count\": 31,\n \"key\": \"Computer Services\"\n },\n {\n \"doc_count\": 8,\n \"key\": \"Management & Consulting\"\n },\n {\n \"doc_count\": 8,\n \"key\": \"Research\"\n },\n {\n \"doc_count\": 4,\n \"key\": \"Advertising\"\n },\n {\n \"doc_count\": 2,\n \"key\": \"Business Services\"\n },\n {\n \"doc_count\": 2,\n \"key\": \"Electronics\"\n }\n ]\n}", "language": "json" } ] } [/block] ### Sample Request using *points* parameter as spatial restriction The **points** parameter must be specified using the fields *top_right/bottom_left* or *top_left/bottom_right* to limit the bounds of the query. [block:code] { "codes": [ { "code": "curl -k -H \"Content-Type: application/json\" -XPOST \"https://api.gogeo.io/1.0/geoagg/my_database/my_collection\" -d '\n{\n \"mapkey\": \"MAP-KEY\",\n \"field\": \"subcategory\",\n \"points\": {\n \"top_left\": [\n -93.07617187499999,\n 47.57652571374621\n ],\n \"bottom_right\": [\n -66.70898437499999,\n 28.613459424004414\n ]\n }\n}'", "language": "json" } ] } [/block] ### Sample Response [block:code] { "codes": [ { "code": "{\n \"buckets_qtd\": 6,\n \"doc_total\": 55,\n \"buckets\": [\n {\n \"doc_count\": 31,\n \"key\": \"Computer Services\"\n },\n {\n \"doc_count\": 8,\n \"key\": \"Management & Consulting\"\n },\n {\n \"doc_count\": 8,\n \"key\": \"Research\"\n },\n {\n \"doc_count\": 4,\n \"key\": \"Advertising\"\n },\n {\n \"doc_count\": 2,\n \"key\": \"Business Services\"\n },\n {\n \"doc_count\": 2,\n \"key\": \"Electronics\"\n }\n ]\n}", "language": "json" } ] } [/block] ### Sample Request using *agg_size* to limit the result size [block:code] { "codes": [ { "code": "curl -k -H \"Content-Type: application/json\" -XPOST \"https://api.gogeo.io/1.0/geoagg/my_database/my_collection\" -d '\n{\n \"mapkey\": \"MAP-KEY\",\n \"field\": \"type\",\n \"points\": {\n \"top_right\": [\n -166.81640625,\n 73.72659470212253\n ],\n \"bottom_left\": [\n -49.92187499999999,\n 26.27371402440643\n ]\n },\n \"agg_size\": 5\n}'", "language": "json" } ] } [/block] ### Sample Response [block:code] { "codes": [ { "code": "{\n \"doc_total\": 189,\n \"buckets_qtd\": 5,\n \"buckets\": [\n {\n \"doc_count\": 146,\n \"key\": \"Services\"\n },\n {\n \"doc_count\": 17,\n \"key\": \"Retail Goods\"\n },\n {\n \"doc_count\": 16,\n \"key\": \"Manufacturing & Wholesale Goods\"\n },\n {\n \"doc_count\": 5,\n \"key\": \"Food & Drink\"\n },\n {\n \"doc_count\": 5,\n \"key\": \"Public Place\"\n }\n ]\n}", "language": "json" } ] } [/block] [block:html] { "html": "<div class=\"panel panel-info teste\" >\n <div class=\"panel-body\">\n This endpoint requires a MAP key. See <a href=\"basic-auth\">Basic Authentication</a> for more information about the goGeo authentication system.\n <br><br>\n If you don't have an access key yet, <a href=\"https://console.gogeo.io/signup\">sign up</a> and grab yours!\n </div>\n</div>" } [/block] --- [block:html] { "html": "<div class='div-middle'> \n <a href='#'>\n Top page &spades; </div>\n </a>\n</div>\n\n<div class='div-back'> \n <a href='/v1.0/docs/geo-aggregation'>\n &laquo; Back \n </a>\n</div>\n\n<style>\n\t.div-back {\n \tpadding-left: 15px;\n\t\tmargin-top: -20px;\n }\n \n .div-middle {\n \ttext-align: center;\n\t\tmargin-top: -15px;\n }\n \n .div-forward {\n \tfloat: right;\n padding-right: 15px;\n\t\tmargin-top: -20px;\n }\n</style>" } [/block]

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}