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

Recommended

Spatial script for MongoBoulder
Spatial script for MongoBoulder
Steven Pousty
 
Spatial script for my JS.Everywhere 2012
Spatial script for my JS.Everywhere 2012
Steven Pousty
 
Script for Spatial Mongo
Script for Spatial Mongo
Steven Pousty
 
Productivity tips for developers
Productivity tips for developers
Sebastian Witowski
 
Sol7
Sol7
University Of Lahore
 
Linux Shell (Expiry of Domain and Certificate)
Linux Shell (Expiry of Domain and Certificate)
Paulo Paim
 
Subversion To Mercurial
Subversion To Mercurial
Ladislav Prskavec
 
computer project code ''payroll'' (based on datafile handling)
computer project code ''payroll'' (based on datafile handling)
Nitish Yadav
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
Chad Cooper
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
 
サイ本 文
サイ本 文
Takashi Takizawa
 
CouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: MapReduce Views
IBM Cloud Data Services
 
Quiz using C++
Quiz using C++
Sushil Mishra
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
Maxym Kharchenko
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTap
Rodolphe Quiédeville
 
Log file analysis by Peter Nikolow
Log file analysis by Peter Nikolow
Anton Shulke
 
CouchDB Day NYC 2017: Full Text Search
CouchDB Day NYC 2017: Full Text Search
IBM Cloud Data Services
 
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
IBM Cloud Data Services
 
CouchDB Day NYC 2017: JSON Documents
CouchDB Day NYC 2017: JSON Documents
IBM Cloud Data Services
 
PHP 机智问答
PHP 机智问答
Shengyou Fan
 
Commit2015 kharchenko - python generators - ext
Commit2015 kharchenko - python generators - ext
Maxym Kharchenko
 
Essential git fu for tech writers
Essential git fu for tech writers
Gaurav Nelson
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X Server
Yasuhiro Asaka
 
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
Fujio Turner
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
Maxym Kharchenko
 
Arp
Arp
Ebsil Sherly
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
Adam Englander
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
Open Stack
 
Spatial script for CIMA
Spatial script for CIMA
Steven Pousty
 
Workshop For pycon13
Workshop For pycon13
Steven Pousty
 

More Related Content

What's hot (20)

Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
Chad Cooper
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
 
サイ本 文
サイ本 文
Takashi Takizawa
 
CouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: MapReduce Views
IBM Cloud Data Services
 
Quiz using C++
Quiz using C++
Sushil Mishra
 
2015 555 kharchenko_ppt
2015 555 kharchenko_ppt
Maxym Kharchenko
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTap
Rodolphe Quiédeville
 
Log file analysis by Peter Nikolow
Log file analysis by Peter Nikolow
Anton Shulke
 
CouchDB Day NYC 2017: Full Text Search
CouchDB Day NYC 2017: Full Text Search
IBM Cloud Data Services
 
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
IBM Cloud Data Services
 
CouchDB Day NYC 2017: JSON Documents
CouchDB Day NYC 2017: JSON Documents
IBM Cloud Data Services
 
PHP 机智问答
PHP 机智问答
Shengyou Fan
 
Commit2015 kharchenko - python generators - ext
Commit2015 kharchenko - python generators - ext
Maxym Kharchenko
 
Essential git fu for tech writers
Essential git fu for tech writers
Gaurav Nelson
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X Server
Yasuhiro Asaka
 
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
Fujio Turner
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
Maxym Kharchenko
 
Arp
Arp
Ebsil Sherly
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
Adam Englander
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
Open Stack
 
Python And GIS - Beyond Modelbuilder And Pythonwin
Python And GIS - Beyond Modelbuilder And Pythonwin
Chad Cooper
 
Javascript Continues Integration in Jenkins with AngularJS
Javascript Continues Integration in Jenkins with AngularJS
Ladislav Prskavec
 
Tests unitaires pour PostgreSQL avec pgTap
Tests unitaires pour PostgreSQL avec pgTap
Rodolphe Quiédeville
 
Log file analysis by Peter Nikolow
Log file analysis by Peter Nikolow
Anton Shulke
 
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
IBM Cloud Data Services
 
Commit2015 kharchenko - python generators - ext
Commit2015 kharchenko - python generators - ext
Maxym Kharchenko
 
Essential git fu for tech writers
Essential git fu for tech writers
Gaurav Nelson
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X Server
Yasuhiro Asaka
 
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
Fujio Turner
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
Maxym Kharchenko
 
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
Adam Englander
 
Openstack at NTT Feb 7, 2011
Openstack at NTT Feb 7, 2011
Open Stack
 

Viewers also liked (9)

Spatial script for CIMA
Spatial script for CIMA
Steven Pousty
 
Workshop For pycon13
Workshop For pycon13
Steven Pousty
 
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
Steven Pousty
 
Spatial mongo for PHP and Zend
Spatial mongo for PHP and Zend
Steven Pousty
 
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Steven Pousty
 
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
Steven Pousty
 
Introduction to PaaS for application developers
Introduction to PaaS for application developers
Steven Pousty
 
Monkigras - dropping science on your developer ecosystem
Monkigras - dropping science on your developer ecosystem
Steven Pousty
 
Build a PaaS with OpenShift Origin
Build a PaaS with OpenShift Origin
Steven Pousty
 
Spatial script for CIMA
Spatial script for CIMA
Steven Pousty
 
Workshop For pycon13
Workshop For pycon13
Steven Pousty
 
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
Steven Pousty
 
Spatial mongo for PHP and Zend
Spatial mongo for PHP and Zend
Steven Pousty
 
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Steven Pousty
 
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
Steven Pousty
 
Introduction to PaaS for application developers
Introduction to PaaS for application developers
Steven Pousty
 
Monkigras - dropping science on your developer ecosystem
Monkigras - dropping science on your developer ecosystem
Steven Pousty
 
Build a PaaS with OpenShift Origin
Build a PaaS with OpenShift Origin
Steven Pousty
 
Ad

Similar to Spatial script for Spatial mongo for PHP and Zend (20)

MongoSF - Spatial MongoDB in OpenShift - script file
MongoSF - Spatial MongoDB in OpenShift - script file
Steven Pousty
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDB
MongoDB
 
MongoDB全機能解説2
MongoDB全機能解説2
Takahiro Inoue
 
Building Your First MongoDB Application
Building Your First MongoDB Application
Rick Copeland
 
Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4
MongoDB
 
Geospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
MongoDB GeoSpatial Feature
MongoDB GeoSpatial Feature
Hüseyin BABAL
 
Building Your First MongoDB Application (Mongo Austin)
Building Your First MongoDB Application (Mongo Austin)
MongoDB
 
Building web applications with mongo db presentation
Building web applications with mongo db presentation
Murat Çakal
 
Building Applications with MongoDB - an Introduction
Building Applications with MongoDB - an Introduction
MongoDB
 
Geospatial and MongoDB
Geospatial and MongoDB
Norberto Leite
 
Building a web application with mongo db
Building a web application with mongo db
MongoDB
 
Script for the geomeetup presentation
Script for the geomeetup presentation
Steven Pousty
 
Open Source Mapping with Python, and MongoDB
Open Source Mapping with Python, and MongoDB
techprane
 
Introduction to MongoDB
Introduction to MongoDB
Nosh Petigara
 
First app online conf
First app online conf
MongoDB
 
Nosh slides mongodb web application - mongo philly 2011
Nosh slides mongodb web application - mongo philly 2011
MongoDB
 
Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011
rogerbodamer
 
Geoindexing with MongoDB
Geoindexing with MongoDB
leafnode
 
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Grant Goodale
 
MongoSF - Spatial MongoDB in OpenShift - script file
MongoSF - Spatial MongoDB in OpenShift - script file
Steven Pousty
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDB
MongoDB
 
MongoDB全機能解説2
MongoDB全機能解説2
Takahiro Inoue
 
Building Your First MongoDB Application
Building Your First MongoDB Application
Rick Copeland
 
Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4
MongoDB
 
Geospatial Indexing and Querying with MongoDB
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
MongoDB GeoSpatial Feature
MongoDB GeoSpatial Feature
Hüseyin BABAL
 
Building Your First MongoDB Application (Mongo Austin)
Building Your First MongoDB Application (Mongo Austin)
MongoDB
 
Building web applications with mongo db presentation
Building web applications with mongo db presentation
Murat Çakal
 
Building Applications with MongoDB - an Introduction
Building Applications with MongoDB - an Introduction
MongoDB
 
Geospatial and MongoDB
Geospatial and MongoDB
Norberto Leite
 
Building a web application with mongo db
Building a web application with mongo db
MongoDB
 
Script for the geomeetup presentation
Script for the geomeetup presentation
Steven Pousty
 
Open Source Mapping with Python, and MongoDB
Open Source Mapping with Python, and MongoDB
techprane
 
Introduction to MongoDB
Introduction to MongoDB
Nosh Petigara
 
First app online conf
First app online conf
MongoDB
 
Nosh slides mongodb web application - mongo philly 2011
Nosh slides mongodb web application - mongo philly 2011
MongoDB
 
Mongo Web Apps: OSCON 2011
Mongo Web Apps: OSCON 2011
rogerbodamer
 
Geoindexing with MongoDB
Geoindexing with MongoDB
leafnode
 
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Mapping Flatland: Using MongoDB for an MMO Crossword Game (GDC Online 2011)
Grant Goodale
 
Ad

More from Steven Pousty (11)

Spatial 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 Management
Steven Pousty
 
Open shift intro for Philly PUG
Open shift intro for Philly PUG
Steven Pousty
 
Open shift intro for Philly PUG
Open shift intro for Philly PUG
Steven Pousty
 
Openshift GeoSpatial Capabilities
Openshift GeoSpatial Capabilities
Steven Pousty
 
Mongo sf spatialmongo
Mongo sf spatialmongo
Steven Pousty
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012
Steven Pousty
 
Free Mongo on OpenShift
Free Mongo on OpenShift
Steven Pousty
 
deCarta at BAPI
deCarta at BAPI
Steven Pousty
 
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Steven Pousty
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 
Spatial 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 Management
Steven Pousty
 
Open shift intro for Philly PUG
Open shift intro for Philly PUG
Steven Pousty
 
Open shift intro for Philly PUG
Open shift intro for Philly PUG
Steven Pousty
 
Openshift GeoSpatial Capabilities
Openshift GeoSpatial Capabilities
Steven Pousty
 
Mongo sf spatialmongo
Mongo sf spatialmongo
Steven Pousty
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012
Steven Pousty
 
Free Mongo on OpenShift
Free Mongo on OpenShift
Steven Pousty
 
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Steven Pousty
 
Using PostGIS To Add Some Spatial Flavor To Your Application
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 

Spatial script for Spatial mongo for PHP and Zend

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