Skip to main content
added 23 characters in body
Source Link
Bera
  • 77.8k
  • 14
  • 78
  • 187

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results doesnt look unreasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select) #If you want to select
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To#Or filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results doesnt look unreasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results doesnt look unreasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select) #If you want to select
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #Or filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

added 9 characters in body
Source Link
Bera
  • 77.8k
  • 14
  • 78
  • 187

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results doesnt look reasonableunreasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results look reasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results doesnt look unreasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

added 75 characters in body
Source Link
Bera
  • 77.8k
  • 14
  • 78
  • 187

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results look reasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results look reasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

Im not sure about the measurements (coordinate system in degrees, distance in meters) but the results look reasonable:

layer = iface.activeLayer()

#https://gis.stackexchange.com/questions/266360/pyqgis-when-we-search-based-on-the-distance-between-two-points-is-the-measurem
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')

search_distance = 50000 #m
map_pos = QgsPointXY(14.4602,57.5751)

to_select = []

for point in layer.getFeatures():
    p = point.geometry()
    p.convertToSingleType()
    if distance.measureLine(p.asPoint(), map_pos) <= search_distance:
        to_select.append(point.id())

layer.select(to_select)
#layer.setSubsetString('id IN{}'.format(tuple(to_select))) #To filter

enter image description here

But there must be a MSSQL equivalent of something like postgis ST_DWithin which must be alot faster than above code?

added 174 characters in body
Source Link
Bera
  • 77.8k
  • 14
  • 78
  • 187
Loading
Source Link
Bera
  • 77.8k
  • 14
  • 78
  • 187
Loading