Skip to main content
2 of 4
edited body
user3716774
  • 333
  • 1
  • 2
  • 7

If I want to find points 100 miles outside a county, what should I do?

Which way is correct? Use distance or buffer? I am not sure about this.

Here is how I use distance:

cursor.execute(""" SELECT COUNT(tw.user_id)
               FROM tweets tw, ca_census_tract ce
               WHERE ST_Distance(ST_Transform(tw.location,26986),
               ST_Transform(ce.geom,26986))>=160934 
               AND ce.name10='Alameda'; """)

cursor.fetchall()

and here is how I use buffer:

cursor.execute(""" SELECT COUNT(tw.user_id)
               FROM tweets tw, ca_census_tract ce
               WHERE ST_within(ST_Transform(tw.location,26986),
               ST_Buffer(ST_Transform(ce.geom,26986), 160934))=false
               AND ce.name10='Alameda'; """)

cursor.fetchall()

The tw.location are points.

Thank you very much!

user3716774
  • 333
  • 1
  • 2
  • 7