Find all locations $geoWithin $geoIntersects Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Do geospatial queries work on arrays? ( $geoWithin, $geoIntersects )Mongodb Geospatial index does not support $box?mongodb $geoIntersects or $geoWithin a point matches multiple polygons - sort by area?MongoDB - $geoWithin query using $polygon or $geometry gives different resultmongodb $geointersects not workinghow to $geoWithin query using “MultiPoint” type?MongoDB $geoIntersects not finding one fully-contained line in polygon, but finding anotherC# MongoDb api - Geojson geometry store into a classD3 - Project Mongo geoJson as points on a map

Why is my ESD wriststrap failing with nitrile gloves on?

Would the Life Transference spell be unbalanced if it ignored resistance and immunity?

AppleTVs create a chatty alternate WiFi network

Using audio cues to encourage good posture

What is a fractional matching?

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

ArcGIS Pro Python arcpy.CreatePersonalGDB_management

Take 2! Is this homebrew Lady of Pain warlock patron balanced?

Localisation of Category

Dating a Former Employee

Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?

Trademark violation for app?

Can a new player join a group only when a new campaign starts?

Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode

How do living politicians protect their readily obtainable signatures from misuse?

How to react to hostile behavior from a senior developer?

Selecting user stories during sprint planning

Why weren't discrete x86 CPUs ever used in game hardware?

Amount of permutations on an NxNxN Rubik's Cube

Can the Great Weapon Master feat's damage bonus and accuracy penalty apply to attacks from the Spiritual Weapon spell?

How can I reduce the gap between left and right of cdot with a macro?

Do I really need to have a message in a novel to appeal to readers?

Chinese Seal on silk painting - what does it mean?

What is the font for "b" letter?



Find all locations $geoWithin $geoIntersects



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Do geospatial queries work on arrays? ( $geoWithin, $geoIntersects )Mongodb Geospatial index does not support $box?mongodb $geoIntersects or $geoWithin a point matches multiple polygons - sort by area?MongoDB - $geoWithin query using $polygon or $geometry gives different resultmongodb $geointersects not workinghow to $geoWithin query using “MultiPoint” type?MongoDB $geoIntersects not finding one fully-contained line in polygon, but finding anotherC# MongoDb api - Geojson geometry store into a classD3 - Project Mongo geoJson as points on a map



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I want to find out which Polygon from a collection, contains the most points from another collection.



I’m using one collection with restaurant data (points) and one with the neighborhood data (polygons)



Both collections are provided by mongodb:



https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json
https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json



Neighborhood document:




"_id":
"$oid": "55cb9c666c522cafdb053a1a"
,
"geometry":
"coordinates": [
[
[
-73.9443878859649,
40.70042452378256
],
[
-73.94424286147482,
40.69969927964773
],
[
-73.94193078816193,
40.70072523469547
],…
]
],
"type": "Polygon"
,
"name": "Bedford"



Restaurant document




"_id" : "$oid" : "55cba2476c522cafdb053add" ,
"location" : "coordinates":[-73.856077,40.848447] , "type":"Point" ,
"name" : "Morris Park Bake Shop"



Here an example to find out all restaurants within a single district:



Select one neighborhood (polygon) by a given point ($geoIntersects)



var neighborhood = db.neighborhoods.findOne( 

geometry:

$geoIntersects:

$geometry: type: "Point", coordinates: [ -73.93414657, 40.82302903 ]



)


Find out how many restaurants are in this neighborhood



db.restaurants.find( location: $geoWithin: $geometry: neighborhood.geometry ).count()


My question:



Which neighborhood contains the most restaurants?










share|improve this question






























    1















    I want to find out which Polygon from a collection, contains the most points from another collection.



    I’m using one collection with restaurant data (points) and one with the neighborhood data (polygons)



    Both collections are provided by mongodb:



    https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json
    https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json



    Neighborhood document:




    "_id":
    "$oid": "55cb9c666c522cafdb053a1a"
    ,
    "geometry":
    "coordinates": [
    [
    [
    -73.9443878859649,
    40.70042452378256
    ],
    [
    -73.94424286147482,
    40.69969927964773
    ],
    [
    -73.94193078816193,
    40.70072523469547
    ],…
    ]
    ],
    "type": "Polygon"
    ,
    "name": "Bedford"



    Restaurant document




    "_id" : "$oid" : "55cba2476c522cafdb053add" ,
    "location" : "coordinates":[-73.856077,40.848447] , "type":"Point" ,
    "name" : "Morris Park Bake Shop"



    Here an example to find out all restaurants within a single district:



    Select one neighborhood (polygon) by a given point ($geoIntersects)



    var neighborhood = db.neighborhoods.findOne( 

    geometry:

    $geoIntersects:

    $geometry: type: "Point", coordinates: [ -73.93414657, 40.82302903 ]



    )


    Find out how many restaurants are in this neighborhood



    db.restaurants.find( location: $geoWithin: $geometry: neighborhood.geometry ).count()


    My question:



    Which neighborhood contains the most restaurants?










    share|improve this question


























      1












      1








      1








      I want to find out which Polygon from a collection, contains the most points from another collection.



      I’m using one collection with restaurant data (points) and one with the neighborhood data (polygons)



      Both collections are provided by mongodb:



      https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json
      https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json



      Neighborhood document:




      "_id":
      "$oid": "55cb9c666c522cafdb053a1a"
      ,
      "geometry":
      "coordinates": [
      [
      [
      -73.9443878859649,
      40.70042452378256
      ],
      [
      -73.94424286147482,
      40.69969927964773
      ],
      [
      -73.94193078816193,
      40.70072523469547
      ],…
      ]
      ],
      "type": "Polygon"
      ,
      "name": "Bedford"



      Restaurant document




      "_id" : "$oid" : "55cba2476c522cafdb053add" ,
      "location" : "coordinates":[-73.856077,40.848447] , "type":"Point" ,
      "name" : "Morris Park Bake Shop"



      Here an example to find out all restaurants within a single district:



      Select one neighborhood (polygon) by a given point ($geoIntersects)



      var neighborhood = db.neighborhoods.findOne( 

      geometry:

      $geoIntersects:

      $geometry: type: "Point", coordinates: [ -73.93414657, 40.82302903 ]



      )


      Find out how many restaurants are in this neighborhood



      db.restaurants.find( location: $geoWithin: $geometry: neighborhood.geometry ).count()


      My question:



      Which neighborhood contains the most restaurants?










      share|improve this question
















      I want to find out which Polygon from a collection, contains the most points from another collection.



      I’m using one collection with restaurant data (points) and one with the neighborhood data (polygons)



      Both collections are provided by mongodb:



      https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/neighborhoods.json
      https://raw.githubusercontent.com/mongodb/docs-assets/geospatial/restaurants.json



      Neighborhood document:




      "_id":
      "$oid": "55cb9c666c522cafdb053a1a"
      ,
      "geometry":
      "coordinates": [
      [
      [
      -73.9443878859649,
      40.70042452378256
      ],
      [
      -73.94424286147482,
      40.69969927964773
      ],
      [
      -73.94193078816193,
      40.70072523469547
      ],…
      ]
      ],
      "type": "Polygon"
      ,
      "name": "Bedford"



      Restaurant document




      "_id" : "$oid" : "55cba2476c522cafdb053add" ,
      "location" : "coordinates":[-73.856077,40.848447] , "type":"Point" ,
      "name" : "Morris Park Bake Shop"



      Here an example to find out all restaurants within a single district:



      Select one neighborhood (polygon) by a given point ($geoIntersects)



      var neighborhood = db.neighborhoods.findOne( 

      geometry:

      $geoIntersects:

      $geometry: type: "Point", coordinates: [ -73.93414657, 40.82302903 ]



      )


      Find out how many restaurants are in this neighborhood



      db.restaurants.find( location: $geoWithin: $geometry: neighborhood.geometry ).count()


      My question:



      Which neighborhood contains the most restaurants?







      mongodb






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 20:26







      nixor quixor

















      asked Mar 8 at 17:43









      nixor quixornixor quixor

      62




      62






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068367%2ffind-all-locations-geowithin-geointersects%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55068367%2ffind-all-locations-geowithin-geointersects%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко