geodjango vs sql query gives different results when filtering points in the polygonExporting lat/long points...

Groups acting on trees

Book where aliens are selecting humans for food consumption

Strange Sign on Lab Door

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

How to avoid being sexist when trying to employ someone to function in a very sexist environment?

Show that the following sequence converges. Please Critique my proof.

What is a jet (unit) shown in Windows 10 calculator?

Help Me simplify: C*(A+B) + ~A*B

If I sold a PS4 game I owned the disc for, can I reinstall it digitally?

Parsing a string of key-value pairs as a dictionary

Why did other German political parties disband so fast when Hitler was appointed chancellor?

Why is working on the same position for more than 15 years not a red flag?

Where are a monster’s hit dice found in the stat block?

Why would the Pakistan airspace closure cancel flights not headed to Pakistan itself?

Can a dragon be stuck looking like a human?

Cryptic with missing capitals

Does Improved Divine Smite trigger when a paladin makes an unarmed strike?

Is there any differences between "Gucken" and "Schauen"?

Why do members of Congress in committee hearings ask witnesses the same question multiple times?

It took me a lot of time to make this, pls like. (YouTube Comments #1)

What is the name of this "living planet" creature?

What to do when being responsible for data protection in your lab, yet advice is ignored?

Solving Fredholm Equation of the second kind

Why does String.replaceAll() work differently in Java 8 from Java 9?



geodjango vs sql query gives different results when filtering points in the polygon


Exporting lat/long points from shapefile gives crazy resultsWhy are the results different for the same point using GEOS Point.transform and Postgis ST_Transform?How to ensure that Tilemill interprets my postgis query as intended?Geodjango - trying to get points within a polygonGeoDjango: Insert geography coordinates and filter the nearest points, step by stepI have two points in my geodjango models when serializing them using drf gis one of them gets renamed and the renamed one doesn't show in haystack?How to find the area of polygon in geodjango?'UPDATE 0' results for ST_Within query - locating points within polygonsFiltering out points inside a polygonFiltering points against polygon













0















I have a django model with the following field:



class PropertyPost(models.Model):
...
location=models.PointField(null=True,blank=True)
...


I am filtering the objects.locations in PgAdmin against a user provided polygon then I would have only points in the polygon as follows:



select propertypost_propertypost.*
From propertypost_propertypost
where st_contains(
St_SetSRID(
'POLYGON((1616523 -172630,1618559 -170395,1612691 -169037,1610057 -170554,1609857 -175464,1611294 -176382,1616523 -172630))'::geometry,
3857),
propertypost_propertypost.location)


this gives me 3 outputs as the result.
Then in my django app I use the following view to do the same filtering:



class PropertyPostList(generics.ListCreateAPIView):
...
def get_queryset(self):
polystr = self.request.query_params.get('poly', None)
if polystr:
poly = GEOSGeometry('SRID=4326;' + polystr)
qs = PropertyPost.objects.filter(location__contained=poly)
return qs


now when I pass the following request it returns 4 results, which include the previous 3 results plus one more:



http://127.0.0.1:8000/prop-posts/?poly=POLYGON((1616523%20-172630,1618559%20-170395,1612691%20-169037,1610057%20-170554,1609857%20-175464,1611294%20-176382,1616523%20-172630))



I was wondering why this two different query gives different results, are they actually different?









share



























    0















    I have a django model with the following field:



    class PropertyPost(models.Model):
    ...
    location=models.PointField(null=True,blank=True)
    ...


    I am filtering the objects.locations in PgAdmin against a user provided polygon then I would have only points in the polygon as follows:



    select propertypost_propertypost.*
    From propertypost_propertypost
    where st_contains(
    St_SetSRID(
    'POLYGON((1616523 -172630,1618559 -170395,1612691 -169037,1610057 -170554,1609857 -175464,1611294 -176382,1616523 -172630))'::geometry,
    3857),
    propertypost_propertypost.location)


    this gives me 3 outputs as the result.
    Then in my django app I use the following view to do the same filtering:



    class PropertyPostList(generics.ListCreateAPIView):
    ...
    def get_queryset(self):
    polystr = self.request.query_params.get('poly', None)
    if polystr:
    poly = GEOSGeometry('SRID=4326;' + polystr)
    qs = PropertyPost.objects.filter(location__contained=poly)
    return qs


    now when I pass the following request it returns 4 results, which include the previous 3 results plus one more:



    http://127.0.0.1:8000/prop-posts/?poly=POLYGON((1616523%20-172630,1618559%20-170395,1612691%20-169037,1610057%20-170554,1609857%20-175464,1611294%20-176382,1616523%20-172630))



    I was wondering why this two different query gives different results, are they actually different?









    share

























      0












      0








      0








      I have a django model with the following field:



      class PropertyPost(models.Model):
      ...
      location=models.PointField(null=True,blank=True)
      ...


      I am filtering the objects.locations in PgAdmin against a user provided polygon then I would have only points in the polygon as follows:



      select propertypost_propertypost.*
      From propertypost_propertypost
      where st_contains(
      St_SetSRID(
      'POLYGON((1616523 -172630,1618559 -170395,1612691 -169037,1610057 -170554,1609857 -175464,1611294 -176382,1616523 -172630))'::geometry,
      3857),
      propertypost_propertypost.location)


      this gives me 3 outputs as the result.
      Then in my django app I use the following view to do the same filtering:



      class PropertyPostList(generics.ListCreateAPIView):
      ...
      def get_queryset(self):
      polystr = self.request.query_params.get('poly', None)
      if polystr:
      poly = GEOSGeometry('SRID=4326;' + polystr)
      qs = PropertyPost.objects.filter(location__contained=poly)
      return qs


      now when I pass the following request it returns 4 results, which include the previous 3 results plus one more:



      http://127.0.0.1:8000/prop-posts/?poly=POLYGON((1616523%20-172630,1618559%20-170395,1612691%20-169037,1610057%20-170554,1609857%20-175464,1611294%20-176382,1616523%20-172630))



      I was wondering why this two different query gives different results, are they actually different?









      share














      I have a django model with the following field:



      class PropertyPost(models.Model):
      ...
      location=models.PointField(null=True,blank=True)
      ...


      I am filtering the objects.locations in PgAdmin against a user provided polygon then I would have only points in the polygon as follows:



      select propertypost_propertypost.*
      From propertypost_propertypost
      where st_contains(
      St_SetSRID(
      'POLYGON((1616523 -172630,1618559 -170395,1612691 -169037,1610057 -170554,1609857 -175464,1611294 -176382,1616523 -172630))'::geometry,
      3857),
      propertypost_propertypost.location)


      this gives me 3 outputs as the result.
      Then in my django app I use the following view to do the same filtering:



      class PropertyPostList(generics.ListCreateAPIView):
      ...
      def get_queryset(self):
      polystr = self.request.query_params.get('poly', None)
      if polystr:
      poly = GEOSGeometry('SRID=4326;' + polystr)
      qs = PropertyPost.objects.filter(location__contained=poly)
      return qs


      now when I pass the following request it returns 4 results, which include the previous 3 results plus one more:



      http://127.0.0.1:8000/prop-posts/?poly=POLYGON((1616523%20-172630,1618559%20-170395,1612691%20-169037,1610057%20-170554,1609857%20-175464,1611294%20-176382,1616523%20-172630))



      I was wondering why this two different query gives different results, are they actually different?







      postgis geodjango





      share












      share










      share



      share










      asked 7 mins ago









      Nabat FarsiNabat Farsi

      83




      83






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "79"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2fgis.stackexchange.com%2fquestions%2f314120%2fgeodjango-vs-sql-query-gives-different-results-when-filtering-points-in-the-poly%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 Geographic Information Systems Stack Exchange!


          • 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%2fgis.stackexchange.com%2fquestions%2f314120%2fgeodjango-vs-sql-query-gives-different-results-when-filtering-points-in-the-poly%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

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          is 'sed' thread safeWhat should someone know about using Python scripts in the shell?Nexenta bash script uses...

          Meter-Bus Содержание Параметры шины | Стандартизация |...