{ "info": { "author": "Rafael Ferraro", "author_email": "rafael.m.ferraro@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# mongo_to_geojson\n\nA tool to help you extract spatial data from Mongo and format into GeoJSON \n\n## Why Use It\n\n - Dump entire collections, use filters (with or without projections), and/or use aggregation framework\n - For geometries, the tool can use either standard geojson geometry objects, or construct point geometries from other document properties 1\n - If you don't provide specific Mongo document properties to use for geometry, this tool attempts to infer geometry. The tool will look for standard geojson geometry objects or other common coordinate naming conventions2\n - Since data is streamed to output json file, this tool won't run out of memory when writing very large geojson files\n\n1. As long as the underlying Mongo value can be converted to a numeric value, this tool can use it. For example, a string value for an x coordinate will be converted just fine (ex: \"x\":\"-104.33\")\n\n2. Common coordinate names this tool looks for below. **Case doesn't matter.**\n\t - x, lng, long, longitude\n\t - y, lat, latitude\n\n## Installation\n\n pip install mongo_to_geojson\n\n## CLI\nThe command line utility mongo2geojson.py is installed along with the pip package\n\n**Simplest use case:** dump a collection to a properly formatted geojson file. As long as the documents in the worldcities collection have either a standard geometry property or a lat/lng values in common formats, no more is needed of you\n\n\n mongo2geojson.py mongodb://localhost/gisdata worldcities worldcities.json\n\n**Advanced use case:** you have finally figured out an aggregate pipeline that answers all your questions. The output of the aggregate does not have a geometry object, nor does it have \"standard\" lat/long properties. Further complicating matters is that some of the output documents will have coordinates in fooX and fooY properties, and other documents in barX and barY properties. And you really don't want to try to copy & paste the aggregate pipeline into the command line - so you save it a file. \n\n mongo2geojson.py mongodb://localhost/gisdata worldcities results.json --agg_pipeline=awesome_aggregate.json --x_possible_names=fooX,barX y_possible_names=fooY,barY\n\nUsing JSON strings as commandline parameters can be quite a boondoggle owing to string escaping. For your own sanity, I'd suggest dumping query, projection, and/or agg_pipeline parameters to a file, and using those file paths as the cli parameters. Should you decide to use JSON strings, there are some subtle differences on how to do so between windows and unix.\n\nunix:\n\n`--query='{\"POP\": {\"$gte\": 100000}}'`\n\nwindows:\n\n`--query=\"{\\\"POP\\\": {\\\"$gte\\\": 100000}}\"`\n\n\n## API\nIntegrate into your own workflows\n\n from mongo_to_geojson import mongo_to_geojson \n\n\tmongo_uri = 'mongodb://localhost/gisdata'\n\tcollection = 'worldcities'\n\toutput_geojson = 'worldcities.json'\n\tquery = {\"POP\": {\"$gte\": 100000}}\n\tprojection = {\"CITY_NAME\": 1, \"x\": 1, \"y\": 1, \"_id\": 0}\n\n try: \n mongo_to_geojson(mongo_uri,collection,output_geojson,query=query,projection=projection) \n except: \n print('mongo_to_geojson no worky'))\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/westchamp24/mongo_to_geojson", "keywords": "mongo geojson", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mongo-to-geojson", "package_url": "https://pypi.org/project/mongo-to-geojson/", "platform": "", "project_url": "https://pypi.org/project/mongo-to-geojson/", "project_urls": { "Homepage": "https://github.com/westchamp24/mongo_to_geojson" }, "release_url": "https://pypi.org/project/mongo-to-geojson/0.2/", "requires_dist": [ "click (>=6.7)", "pymongo (>=3.7.1)" ], "requires_python": "", "summary": "extract geojson from Mongo", "version": "0.2" }, "last_serial": 4277721, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "6b1b0f5c3fb4feb019705ede46757a17", "sha256": "d75adaa61b691f9fa86d02cac5a55dbda428840ee80692d040987bf1db0d7aab" }, "downloads": -1, "filename": "mongo_to_geojson-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6b1b0f5c3fb4feb019705ede46757a17", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6650, "upload_time": "2018-09-17T00:02:17", "url": "https://files.pythonhosted.org/packages/67/d2/d6d2f8a6666b93ae7a68f3a1e4ec885bfa5d7c745c5614be12232fe82d77/mongo_to_geojson-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6954b9a243d50cdd0722ab54185c7d58", "sha256": "8ec6b9b1277c95cc27fa2240c9c7d75e0e2d1f09a297c643c5c5fa8a67471970" }, "downloads": -1, "filename": "mongo_to_geojson-0.2.tar.gz", "has_sig": false, "md5_digest": "6954b9a243d50cdd0722ab54185c7d58", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6467, "upload_time": "2018-09-17T00:02:18", "url": "https://files.pythonhosted.org/packages/94/57/632b7ec8a72a3c3d18f844eceb236845e708c090c61f43796a9b39b74468/mongo_to_geojson-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6b1b0f5c3fb4feb019705ede46757a17", "sha256": "d75adaa61b691f9fa86d02cac5a55dbda428840ee80692d040987bf1db0d7aab" }, "downloads": -1, "filename": "mongo_to_geojson-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6b1b0f5c3fb4feb019705ede46757a17", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6650, "upload_time": "2018-09-17T00:02:17", "url": "https://files.pythonhosted.org/packages/67/d2/d6d2f8a6666b93ae7a68f3a1e4ec885bfa5d7c745c5614be12232fe82d77/mongo_to_geojson-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6954b9a243d50cdd0722ab54185c7d58", "sha256": "8ec6b9b1277c95cc27fa2240c9c7d75e0e2d1f09a297c643c5c5fa8a67471970" }, "downloads": -1, "filename": "mongo_to_geojson-0.2.tar.gz", "has_sig": false, "md5_digest": "6954b9a243d50cdd0722ab54185c7d58", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6467, "upload_time": "2018-09-17T00:02:18", "url": "https://files.pythonhosted.org/packages/94/57/632b7ec8a72a3c3d18f844eceb236845e708c090c61f43796a9b39b74468/mongo_to_geojson-0.2.tar.gz" } ] }