SlideShare a Scribd company logo
1 of 1
Download to read offline
1   #commands for adding spatial data
 2
 3   #Take a look at the file first
 4   less parkcoord.json
 5   #get the file on the server
 6   scp parkcoord.json 0b49d9219f2847c6a236820959f9a@parks-spmongo.rhcloud.com:parks/data/
 7
 8   #ssh into the machine
 9   ssh 0b49d9219f2847c6a236820959f9a@parks-spmongo.rhcloud.com
10
11   #import into mongo
12   mongoimport -d parks -c opencloud --type json --file parks/data/parkcoord.json   -h $OPENSHIFT_NOSQL_DB_HOST   -u admin -p
13
14   #open the mongo shell
15   mongo -u admin -p $OPENSHIFT_NOSQL_DB_HOST/parks
16
17   #build the index
18   db.opencloud.ensureIndex({"pos":"2d"});
19
20   #Now some queries
21   #simple spatial
22   db.opencloud.find({"pos" : { "$near" : [-37, 41]}});
23
24   #spatial and text query using regex
25   db.opencloud.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );
26
27   #geonear TODO
28   db.runCommand({ geoNear : "opencloud", near : [-37,41], num : 10 });
29
30
31   #create a new collection from scratch
32   db.createCollection("clouduserloc");
33   db.clouduserloc.ensureIndex( { pos : "2d" } );
34
35   #insert a new record
36   db.clouduserloc.insert({ "created" : new Date(), "Notes" : 'just landed', "pos" : [-76.7302 , 25.5332 ] })
37   !
38   #quick query to make sure it worked
39   db.clouduserloc.find( { pos : { $near : [-37,41] } } )
40
41   #add a second document closer to query point
42   #this is an upsert - since we don't pass in the _id it creates a new record
43   db.clouduserloc.save({ created : new Date(), Notes: 'that was a big step', pos : [-37.7302 , 40.5332 ]});
44
45   #one way to update original document
46   myDoc = db.clouduserloc.findOne({_id : ObjectId("ID for the first object")});
47   myDoc.Notes = "really the landing";
48   db.clouduserloc.save(myDoc);
49

More Related Content

What's hot

Chapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-filesChapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-files
Deepak Singh
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
Open Stack
 
37562259 top-consuming-process
37562259 top-consuming-process37562259 top-consuming-process
37562259 top-consuming-process
skumner
 

What's hot (20)

Arp
ArpArp
Arp
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...
 
Angular Refactoring in Real World
Angular Refactoring in Real WorldAngular Refactoring in Real World
Angular Refactoring in Real World
 
Designate Installation Workshop
Designate Installation WorkshopDesignate Installation Workshop
Designate Installation Workshop
 
Designate - Operators Deep Dive
Designate - Operators Deep DiveDesignate - Operators Deep Dive
Designate - Operators Deep Dive
 
2009 Itc Nslookup Rev01
2009 Itc Nslookup Rev012009 Itc Nslookup Rev01
2009 Itc Nslookup Rev01
 
Sol10
Sol10Sol10
Sol10
 
Knot.x 1.X / 2.0 roadmap
Knot.x 1.X / 2.0 roadmapKnot.x 1.X / 2.0 roadmap
Knot.x 1.X / 2.0 roadmap
 
Chapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-filesChapter21 separate-header-and-implementation-files
Chapter21 separate-header-and-implementation-files
 
サイ本 文
サイ本 文サイ本 文
サイ本 文
 
Dns centos
Dns centosDns centos
Dns centos
 
Coding with Vim
Coding with VimCoding with Vim
Coding with Vim
 
Program to implement searching in a text file
Program to implement searching in a text fileProgram to implement searching in a text file
Program to implement searching in a text file
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
 
201801 CSE240 Lecture 12
201801 CSE240 Lecture 12201801 CSE240 Lecture 12
201801 CSE240 Lecture 12
 
Linked list : Doubly Linked List
Linked list : Doubly Linked ListLinked list : Doubly Linked List
Linked list : Doubly Linked List
 
DNS 101: Introducción a DNS en Español
DNS 101: Introducción a DNS en EspañolDNS 101: Introducción a DNS en Español
DNS 101: Introducción a DNS en Español
 
Deploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard WayDeploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard Way
 
37562259 top-consuming-process
37562259 top-consuming-process37562259 top-consuming-process
37562259 top-consuming-process
 
Setting ubuntu server sebagai pc router
Setting ubuntu server sebagai pc routerSetting ubuntu server sebagai pc router
Setting ubuntu server sebagai pc router
 

Similar to Script for Spatial Mongo

Spatial script for CIMA
Spatial script for CIMASpatial script for CIMA
Spatial script for CIMA
Steven Pousty
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
kchodorow
 
containerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brusselscontainerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brussels
Daniel Nüst
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
ronnywang_tw
 

Similar to Script for Spatial Mongo (20)

MongoSF - Spatial MongoDB in OpenShift - script file
MongoSF - Spatial MongoDB in OpenShift - script fileMongoSF - Spatial MongoDB in OpenShift - script file
MongoSF - Spatial MongoDB in OpenShift - script file
 
Spatial script for CIMA
Spatial script for CIMASpatial script for CIMA
Spatial script for CIMA
 
9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab9b. Document-Oriented Databases lab
9b. Document-Oriented Databases lab
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
Back to Basics Webinar 2 - Your First MongoDB Application
Back to  Basics Webinar 2 - Your First MongoDB ApplicationBack to  Basics Webinar 2 - Your First MongoDB Application
Back to Basics Webinar 2 - Your First MongoDB Application
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"
 
Living the Nomadic life - Nic Jackson
Living the Nomadic life - Nic JacksonLiving the Nomadic life - Nic Jackson
Living the Nomadic life - Nic Jackson
 
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
Webinaire 2 de la série « Retour aux fondamentaux » : Votre première applicat...
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
Nomad Multi-Cloud
Nomad Multi-CloudNomad Multi-Cloud
Nomad Multi-Cloud
 
PySpark in practice slides
PySpark in practice slidesPySpark in practice slides
PySpark in practice slides
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.
 
Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)Functional Operations (Functional Programming at Comcast Labs Connect)
Functional Operations (Functional Programming at Comcast Labs Connect)
 
containerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brusselscontainerit at useR!2017 conference, Brussels
containerit at useR!2017 conference, Brussels
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Hacking for fun and profit
Hacking for fun and profitHacking for fun and profit
Hacking for fun and profit
 
Building Your Own IoT Platform using FIWARE GEis
Building Your Own IoT Platform using FIWARE GEisBuilding Your Own IoT Platform using FIWARE GEis
Building Your Own IoT Platform using FIWARE GEis
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
NDC London 2013 - Mongo db for c# developers
NDC London 2013 - Mongo db for c# developersNDC London 2013 - Mongo db for c# developers
NDC London 2013 - Mongo db for c# developers
 

More from Steven Pousty

APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + DockerAPPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Steven Pousty
 
Workshop For pycon13
Workshop For pycon13Workshop For pycon13
Workshop For pycon13
Steven Pousty
 
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Steven Pousty
 
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem ManagementDropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Steven Pousty
 
Mongo sf spatialmongo
Mongo sf spatialmongoMongo sf spatialmongo
Mongo sf spatialmongo
Steven Pousty
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your ApplicationUsing PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 

More from Steven Pousty (20)

APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + DockerAPPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
 
Introduction to PaaS for application developers
Introduction to PaaS for application developersIntroduction to PaaS for application developers
Introduction to PaaS for application developers
 
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
London Cloud Summit 2014  - raising the tide: getting developers in the cloudLondon Cloud Summit 2014  - raising the tide: getting developers in the cloud
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
 
Workshop For pycon13
Workshop For pycon13Workshop For pycon13
Workshop For pycon13
 
Build a PaaS with OpenShift Origin
Build a PaaS with OpenShift OriginBuild a PaaS with OpenShift Origin
Build a PaaS with OpenShift Origin
 
Monkigras - dropping science on your developer ecosystem
Monkigras - dropping science on your developer ecosystemMonkigras - dropping science on your developer ecosystem
Monkigras - dropping science on your developer ecosystem
 
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
Spatial MongoDB, Node.JS, and Express - server-side JS for your applicationSpatial MongoDB, Node.JS, and Express - server-side JS for your application
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
 
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
 
Spatial mongo for PHP and Zend
Spatial mongo for PHP and ZendSpatial mongo for PHP and Zend
Spatial mongo for PHP and Zend
 
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem ManagementDropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
 
Open shift intro for Philly PUG
Open shift intro for Philly PUGOpen shift intro for Philly PUG
Open shift intro for Philly PUG
 
Open shift intro for Philly PUG
Open shift intro for Philly PUGOpen shift intro for Philly PUG
Open shift intro for Philly PUG
 
Script for the geomeetup presentation
Script for the geomeetup presentationScript for the geomeetup presentation
Script for the geomeetup presentation
 
Openshift GeoSpatial Capabilities
Openshift GeoSpatial CapabilitiesOpenshift GeoSpatial Capabilities
Openshift GeoSpatial Capabilities
 
Mongo sf spatialmongo
Mongo sf spatialmongoMongo sf spatialmongo
Mongo sf spatialmongo
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012
 
Free Mongo on OpenShift
Free Mongo on OpenShiftFree Mongo on OpenShift
Free Mongo on OpenShift
 
deCarta at BAPI
deCarta at BAPI deCarta at BAPI
deCarta at BAPI
 
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your AppLinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your ApplicationUsing PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
 

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 

Recently uploaded (20)

Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101AI presentation and introduction - Retrieval Augmented Generation RAG 101
AI presentation and introduction - Retrieval Augmented Generation RAG 101
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
FDO for Camera, Sensor and Networking Device – Commercial Solutions from VinC...
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
1111 ChatGPT Prompts PDF Free Download - Prompts for ChatGPT
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Your enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4jYour enemies use GenAI too - staying ahead of fraud with Neo4j
Your enemies use GenAI too - staying ahead of fraud with Neo4j
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 

Script for Spatial Mongo

  • 1. 1 #commands for adding spatial data 2 3 #Take a look at the file first 4 less parkcoord.json 5 #get the file on the server 6 scp parkcoord.json 0b49d9219f2847c6a236820959f9a@parks-spmongo.rhcloud.com:parks/data/ 7 8 #ssh into the machine 9 ssh 0b49d9219f2847c6a236820959f9a@parks-spmongo.rhcloud.com 10 11 #import into mongo 12 mongoimport -d parks -c opencloud --type json --file parks/data/parkcoord.json -h $OPENSHIFT_NOSQL_DB_HOST -u admin -p 13 14 #open the mongo shell 15 mongo -u admin -p $OPENSHIFT_NOSQL_DB_HOST/parks 16 17 #build the index 18 db.opencloud.ensureIndex({"pos":"2d"}); 19 20 #Now some queries 21 #simple spatial 22 db.opencloud.find({"pos" : { "$near" : [-37, 41]}}); 23 24 #spatial and text query using regex 25 db.opencloud.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} ); 26 27 #geonear TODO 28 db.runCommand({ geoNear : "opencloud", near : [-37,41], num : 10 }); 29 30 31 #create a new collection from scratch 32 db.createCollection("clouduserloc"); 33 db.clouduserloc.ensureIndex( { pos : "2d" } ); 34 35 #insert a new record 36 db.clouduserloc.insert({ "created" : new Date(), "Notes" : 'just landed', "pos" : [-76.7302 , 25.5332 ] }) 37 ! 38 #quick query to make sure it worked 39 db.clouduserloc.find( { pos : { $near : [-37,41] } } ) 40 41 #add a second document closer to query point 42 #this is an upsert - since we don't pass in the _id it creates a new record 43 db.clouduserloc.save({ created : new Date(), Notes: 'that was a big step', pos : [-37.7302 , 40.5332 ]}); 44 45 #one way to update original document 46 myDoc = db.clouduserloc.findOne({_id : ObjectId("ID for the first object")}); 47 myDoc.Notes = "really the landing"; 48 db.clouduserloc.save(myDoc); 49