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

More Related Content

What's hot (20)

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

Viewers also liked (9)

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

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

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

More from Steven Pousty (11)

PPTX
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Steven Pousty
 
PPTX
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Steven Pousty
 
PDF
Open shift intro for Philly PUG
Steven Pousty
 
PPT
Open shift intro for Philly PUG
Steven Pousty
 
PPT
Openshift GeoSpatial Capabilities
Steven Pousty
 
PPT
Mongo sf spatialmongo
Steven Pousty
 
PPTX
OpenShift with Eclipse Tooling - EclipseCon 2012
Steven Pousty
 
PPTX
Free Mongo on OpenShift
Steven Pousty
 
PPTX
deCarta at BAPI
Steven Pousty
 
PPT
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Steven Pousty
 
PPT
Using PostGIS To Add Some Spatial Flavor To Your Application
Steven Pousty
 
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Steven Pousty
 
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Steven Pousty
 
Open shift intro for Philly PUG
Steven Pousty
 
Open shift intro for Philly PUG
Steven Pousty
 
Openshift GeoSpatial Capabilities
Steven Pousty
 
Mongo sf spatialmongo
Steven Pousty
 
OpenShift with Eclipse Tooling - EclipseCon 2012
Steven Pousty
 
Free Mongo on OpenShift
Steven Pousty
 
deCarta at BAPI
Steven Pousty
 
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Steven Pousty
 
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