{"__v":17,"_id":"5501d14df2ef1e0d003116ba","category":{"__v":12,"_id":"54fdff31f7b1202100a25e06","pages":["54fdff6bf7b1202100a25e07","54fdff85f7b1202100a25e09","54fdffa1f7b1202100a25e0b","54fdffc25de33c2d0031127a","54fdffe5f7b1202100a25e0e","550199dc0459bd3700770d87","5501d14df2ef1e0d003116ba","5501d1e70459bd3700770e1c","5501d1f4f2ef1e0d003116bd","5501d20f0459bd3700770e1e","5501d2220459bd3700770e20","5501ecbaf2ef1e0d0031171d"],"project":"54d0fd1d095c470d00d1646d","version":"54d0fd1e095c470d00d16470","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-03-09T20:14:41.719Z","from_sync":false,"order":1,"slug":"tutorials","title":"Tutorials"},"project":"54d0fd1d095c470d00d1646d","user":"54db5301eb78f13900cf108b","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-03-12T17:47:57.770Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"To import your data first you need to create a collection related to a database previously created. See [Creating a database](doc:creating-a-database) tutorial to learn how to create a database. The **goGeo** platform provides some tools to perform these tasks, you can use the Console or access some API endpoints. The follows enumerated sections describe ways to create collections:\n\n1. [Creating a Collection by Console](/v1.0/docs/creating-a-collection#creating-a-collection-by-console);\n2. [Creating a Collection by API](/v1.0/docs/creating-a-collection#creating-a-collection-by-api);\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating a Collection by Console\"\n}\n[/block]\nIn the Console, click on the **Databases** item on the left side menu of the console to enter the database management screen.\n\nNext, on the right side of the database name there is a cloud icon to create a new collection from a data file (Figure 1).\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Figure 1 - Link to insert a new collection.\",\n      \"image\": [\n        \"https://files.readme.io/ebT9Sa3RD6dgDThwc5AV_001_fig04.png\",\n        \"001_fig04.png\",\n        \"755\",\n        \"424\",\n        \"#4270ac\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nClick on icon corresponding the database you've just created. A file insertion form will be displayed on the details box (Figure 2). This form allows to enter the name of the new collection (with the same rules of dababase's name) and a *URL* for the file that will be imported.\n\nYou can import files publicly available on the WEB on your website or virtual disks like Dropbox and Copy. Files with or without compression in Shapefile or *\"CSV goGeo format\"* are accepted. Details about supported file format can be found [Database Management](doc:database-management)  [**here**](doc:database-management) .\n\nFor convenience, we have provided on Dropbox a small sample file in CSV format that you can use to load in order to try goGeo Console. This file contains one thousand (1000) records about companies in USA.\n\nEnter a name for the collection (we suggest **tutorial_collection**) and copy the address below to the file *URL* field, then click on the [**Send**] button.\n\n~~~\nhttps://www.dropbox.com/s/47i6toeuj6wwvv7/simpleGeoUS_1k.csv.tar.bz2?dl=1\n~~~\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Figure 2 - Data from the new collection to insert.\",\n      \"image\": [\n        \"https://files.readme.io/xUeGZU4cStiqpL5j7iPE_001_fig05.png\",\n        \"001_fig05.png\",\n        \"844\",\n        \"475\",\n        \"#5298d6\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n**Next, the form will close....** The insertion progress can be monitored through Tasks Service. On success, the column operation will show a green tick with the operation name (insert, in this case), as ilustrated in Figure 3.\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Figure 3 - Example of monitoring the success task of importing data.\",\n      \"image\": [\n        \"https://files.readme.io/OB086EXMRh2YaCd1sxrQ_001_fig06.png\",\n        \"001_fig06.png\",\n        \"1779\",\n        \"469\",\n        \"#5cb861\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIf something wrong happens, the column Operation will show a red 'X' with the name of the operation that has failed, as shown in Figure 4.\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Figure 4 - Example of a task with error of importing data.\",\n      \"image\": [\n        \"https://files.readme.io/ixcRrvh3TMmClx34lWVV_001_fig07.png\",\n        \"001_fig07.png\",\n        \"1302\",\n        \"200\",\n        \"#62b459\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nClicking on the operation name, a window will appear (Figure 5) with the message error.\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Figure 5 - Window with the operation message error.\",\n      \"image\": [\n        \"https://files.readme.io/gfoi0MkTnmbT5B82Xb2w_001_fig08.png\",\n        \"001_fig08.png\",\n        \"1156\",\n        \"268\",\n        \"#5c281e\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIn this case, we tried to import a file with \".7z\" format, which it is not supported.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating a Collection by API\"\n}\n[/block]\nTo create your own collection via API, you will first need your API-KEY. You will need to get in the Console.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"body\": \"You need to create an account to get your own API-KEY.\",\n  \"title\": \"NOTE\"\n}\n[/block]\nWith the API-KEY in hands, you just need make a POST request. You can do this using some tools. Below we can see example(s).\n\n### cURL\nOpen a terminal;\n\nExecuting the follow command:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -k --user {apikey}: -H \\\"Content-Type: application/json\\\" -XPOST \\\\\\n\\\"https://api.gogeo.io/1.0/databases/{database_name}/collections\\\" -d '\\n{\\n\\t\\\"collection_name\\\": \\\"{collection_name}\\\"\\n}'\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\nThis will create a collection. Just replace *{apikey}* by your own API-KEY, *{database_name}* by the name of database that will contain your new collection and *{collection_name}* by the name you desire to the new collection.\n\nCongratulations, you already have your collection created.\n\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/creating-a-database'>\\n    &laquo; Back \\n  </a>\\n</div>\\n\\n<div class='div-forward'> \\n  <a href='/v1.0/docs/importing-data'>\\n    Next &raquo; </div>\\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":"Learn how to create collections.","slug":"creating-a-collection","type":"basic","title":"Creating a collection"}

Creating a collection

Learn how to create collections.

To import your data first you need to create a collection related to a database previously created. See [Creating a database](doc:creating-a-database) tutorial to learn how to create a database. The **goGeo** platform provides some tools to perform these tasks, you can use the Console or access some API endpoints. The follows enumerated sections describe ways to create collections: 1. [Creating a Collection by Console](/v1.0/docs/creating-a-collection#creating-a-collection-by-console); 2. [Creating a Collection by API](/v1.0/docs/creating-a-collection#creating-a-collection-by-api); [block:api-header] { "type": "basic", "title": "Creating a Collection by Console" } [/block] In the Console, click on the **Databases** item on the left side menu of the console to enter the database management screen. Next, on the right side of the database name there is a cloud icon to create a new collection from a data file (Figure 1). [block:image] { "images": [ { "caption": "Figure 1 - Link to insert a new collection.", "image": [ "https://files.readme.io/ebT9Sa3RD6dgDThwc5AV_001_fig04.png", "001_fig04.png", "755", "424", "#4270ac", "" ] } ] } [/block] Click on icon corresponding the database you've just created. A file insertion form will be displayed on the details box (Figure 2). This form allows to enter the name of the new collection (with the same rules of dababase's name) and a *URL* for the file that will be imported. You can import files publicly available on the WEB on your website or virtual disks like Dropbox and Copy. Files with or without compression in Shapefile or *"CSV goGeo format"* are accepted. Details about supported file format can be found [Database Management](doc:database-management) [**here**](doc:database-management) . For convenience, we have provided on Dropbox a small sample file in CSV format that you can use to load in order to try goGeo Console. This file contains one thousand (1000) records about companies in USA. Enter a name for the collection (we suggest **tutorial_collection**) and copy the address below to the file *URL* field, then click on the [**Send**] button. ~~~ https://www.dropbox.com/s/47i6toeuj6wwvv7/simpleGeoUS_1k.csv.tar.bz2?dl=1 ~~~ [block:image] { "images": [ { "caption": "Figure 2 - Data from the new collection to insert.", "image": [ "https://files.readme.io/xUeGZU4cStiqpL5j7iPE_001_fig05.png", "001_fig05.png", "844", "475", "#5298d6", "" ] } ] } [/block] **Next, the form will close....** The insertion progress can be monitored through Tasks Service. On success, the column operation will show a green tick with the operation name (insert, in this case), as ilustrated in Figure 3. [block:image] { "images": [ { "caption": "Figure 3 - Example of monitoring the success task of importing data.", "image": [ "https://files.readme.io/OB086EXMRh2YaCd1sxrQ_001_fig06.png", "001_fig06.png", "1779", "469", "#5cb861", "" ] } ] } [/block] If something wrong happens, the column Operation will show a red 'X' with the name of the operation that has failed, as shown in Figure 4. [block:image] { "images": [ { "caption": "Figure 4 - Example of a task with error of importing data.", "image": [ "https://files.readme.io/ixcRrvh3TMmClx34lWVV_001_fig07.png", "001_fig07.png", "1302", "200", "#62b459", "" ] } ] } [/block] Clicking on the operation name, a window will appear (Figure 5) with the message error. [block:image] { "images": [ { "caption": "Figure 5 - Window with the operation message error.", "image": [ "https://files.readme.io/gfoi0MkTnmbT5B82Xb2w_001_fig08.png", "001_fig08.png", "1156", "268", "#5c281e", "" ] } ] } [/block] In this case, we tried to import a file with ".7z" format, which it is not supported. [block:api-header] { "type": "basic", "title": "Creating a Collection by API" } [/block] To create your own collection via API, you will first need your API-KEY. You will need to get in the Console. [block:callout] { "type": "danger", "body": "You need to create an account to get your own API-KEY.", "title": "NOTE" } [/block] With the API-KEY in hands, you just need make a POST request. You can do this using some tools. Below we can see example(s). ### cURL Open a terminal; Executing the follow command: [block:code] { "codes": [ { "code": "curl -k --user {apikey}: -H \"Content-Type: application/json\" -XPOST \\\n\"https://api.gogeo.io/1.0/databases/{database_name}/collections\" -d '\n{\n\t\"collection_name\": \"{collection_name}\"\n}'", "language": "curl" } ] } [/block] This will create a collection. Just replace *{apikey}* by your own API-KEY, *{database_name}* by the name of database that will contain your new collection and *{collection_name}* by the name you desire to the new collection. Congratulations, you already have your collection created. --- [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/creating-a-database'>\n &laquo; Back \n </a>\n</div>\n\n<div class='div-forward'> \n <a href='/v1.0/docs/importing-data'>\n Next &raquo; </div>\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]