Questions tagged [spatial-query]

A query for geometric features based on their spatial relationship.

Filter by
Sorted by
Tagged with
14
votes
1answer
8k views

What is difference between ST_DWithin and ST_Distance for proximity search in PostGIS?

I have records stored in a table with latitude/longitude coordinates stored in a geometry field. I want to find all records nearby a user supplied reference point. Note "nearby" probably means less ...
11
votes
2answers
370 views

Identify points in a shapefile that have no other point within x km with QGIS

This is probably a naive question but I am struggling as a new user to QGIS. I have a very large shapefile (275,000 points, but can break this into about 10 subregions if necessary for faster ...
10
votes
3answers
11k views

Where is Spatial query in QGIS3?

I just installed QGIS 3.0 EA. I wonder where the Spatial query is? There is a ”count points in polygon” in the toolbox but it can’t count point within a polygon.
9
votes
3answers
4k views

Performing a Spatial Query in a loop in PyQGIS

What I am trying to do: loop through a point shapefile and select each point that falls into a polygon. The following code is inspired by a spatial query example I found in a book: mitte_path = r"D:\...
7
votes
1answer
1k views

How to build a query/expression to select specific points within a buffer? (in QGIS)

I have a point layer in QGIS. Each point represents a tree and each tree has information about its height as an attribute. I would like to build a query/expression to select all those trees that have ...
7
votes
1answer
2k views

How to use qgis:selectbylocation in PyQGIS?

I am trying to use the processing toolbox to perform a spatial query (points in polygon). I am not sure how to use the tool and I keep getting Error: Wrong number of parameters. Here is my script: ...
7
votes
2answers
765 views

Find start of river

Edit: Follow-up question here (= Find headwater polygons). How can I determine the start of a river in PostGIS? I have a river network (Multiline) and want to find the startpoints of the rivers. I ...
6
votes
4answers
2k views

Is there a way to use a spatial query to invert X and Y coordinates in QGIS?

Original problem : I tend to often invert X & Y in WGS84 lat/long CSV import. I'm wondering now if there is a way not to reimport the original file (as this is the basic solution for points) and ...
6
votes
2answers
15k views

PostGIS ST within does not exist

I'm quite new to postgresql and postgis so this error will probably due to some rookie mistake. I want to run the spatial query ST_within. When I describe the query like this SELECT nw.entity_id AS ...
5
votes
2answers
796 views

PostGIS: Strategy for fastest select by BBox with an ORDER BY polygon area clause. Cluster?

Update 2 (below) suggests 14% of the table geometries are stored out-of-line with the rest of the table records. This may be a useful clue. The Problem: We've got a table with appx 170,000 WGS84 ...
5
votes
2answers
248 views

How to select random adjacent census tract

I have set of census tracts spaced out across a city and I would like to randomly choose an adjacent census tract to explore nearby demographic data. I'm not sure if there is an easy process for ...
4
votes
2answers
4k views

Update field based on spatial query (QGIS)

I was an intermediate user of MapInfo and have recently converted to QGIS. I would often use MapInfo to add a column in boundary file A saying which zone in boundary file B it is contained in. However,...
4
votes
2answers
4k views

Postgis, get the points that are x meters near another point, in meters

I'm trying to find the points within a certain distance, in meters, from another point. I'm using the function ST_Buffer, but I don't get how to express the distance in meters. I'm trying with ...
4
votes
3answers
2k views

Selecting Counties within Region via Spatial Query using QGIS/PostGIS?

I'm using GQIS 2.2 and PostGIS on Postgresql 9.3. I have 5 regions in the contiguous United States. Each region has states, and each state has counties. I would like to think that the data I'm given ...
4
votes
1answer
308 views

Is it possible to have R write out .sbn and .sbx files?

I'm working on an situation where a client wants, in addition to the .shp & .prj files that I can produce with e.g. rgdal::writeOGR, the .sbn & .sbx files as well. My understanding is this is ...
4
votes
1answer
2k views

Finding State, County, Place, and Census Block FIPS codes from a coordinate (latitude and longitude)

I am looking for a way to gather the political areas (ie FIPS codes) from a latitude and longitude coordinate. For example, if I were to input the coordinates: 47.66955, -122.31259 (Downtown Seattle),...
4
votes
1answer
198 views

Calculating mileage from linestring

I'm looking to calculate the approximate distance in miles from a linestring. This post recommends using ST_Transform in conjunction with the State Plane coordinate system for my area. In my case, I ...
4
votes
3answers
964 views

Quickly make server side spatial filters for WFS layers based on other layer's selected geometries in QGIS

In QGIS 2.12.1, I have a WFS layer which is huge so I don't want my users to load it entirely but only parts of it based on intersections with geometries. Today, I'm using the query builder and ...
4
votes
1answer
223 views

Find Co-located points in single layer

I have a layer (currently the source is a csv file) with 130,000 points. Many of these points are co-located in a building room. How can I identify points that are within a small distance of another ...
4
votes
1answer
218 views

PyQGIS spatial operators(contains,equals,etc.) w.r.t. layer geometries(polygon,point,line,etc.)

I am trying to implement QGIS spatial query functionality in my plugin. I want to eliminate spatial operators which are not suitable for certain geometries. For eg. when I select layer with point ...
3
votes
1answer
8k views

spatial query st_contains postgis

This seems too simple to be asking this but I am really new to PostGIS/Postgres have been going around in circles with this. I am performing a really simple spatial query where I would like to make a ...
3
votes
3answers
1k views

List IDs of polygons within another polygon in the attribute table

I have two polygon shapefiles in QGIS I would like to have the polygon IDs of B listed in the attribute table of A for the case that they overlap. As a demonstration: I tried combinations of ...
3
votes
2answers
158 views

Selecting lines where start and end points within polygon using Virtual Layer

In QGIS 2.18 project there are several layers, lines and polygons respectively My task is to select all lines when their start and end points are laying within polygons using Virtual Layer, see image ...
3
votes
2answers
1k views

Spatial Definition Queries?

Is it possible to spatially pre-clip layers (say with a IPolygon object) before they are loaded into ArcMap? This would be a bit like a query definition but spatial and for raster data.
3
votes
2answers
199 views

Test if a spatial query contains another

I have two tables : country and regions. Country contains all the Europeans countries and regions contains some subdivisions of those countries. I created a small Union of some countries and regions. ...
3
votes
2answers
379 views

QGIS Spatial query error

I have a layer of a csv file with around 700k rows and a polygon layer, both are in wgs84. I'm trying with the spatial query to calculate what point are in the polygons. The problem is that the ...
3
votes
1answer
4k views

Get the width and height of a rectangular polygon in PostGIS

I have a table with point features saved in the my PostgreSQL database, and I can run the following query to get the extent of the point features and I turned the extent back into a geometry: SELECT ...
3
votes
2answers
74 views

Locating where different polygons (buffer rings) from different layers are intersected based on same attribute value (QGIS)

I need to locate where different polygons (buffer rings) from different layers are intersected based on a same attribute value. As shown in the figure, there are different buffer rings from different ...
3
votes
3answers
3k views

QGIS spatial join, calculating distance from polygon to point layer

I am trying to perform a kind of 'spatial join' in Arcgis, joining to a polygon layer atributes of the closest feature of a point layer, as well as distance. But 'spatial query' doesn't offer an ...
3
votes
1answer
57 views

One Record Two Point Geometries - Point-in-polygon

The trip data contains the origin-destination of each trip, and both origin and destination are stored as geometries. How could I retrieve the origin and destination polygons that the points are ...
3
votes
3answers
2k views

Remove islands and completely surrounded polygons after polygonization with QGIS

I have a line map of buildings in a city. I was able to correctly polygonize the buildings in QGIS with the Polygonize processing algorithm. All the holes/islands became features as expected. Now I ...
3
votes
1answer
39 views

Making UPDATE for coordinate does not return the same value

Being totally new with PostGIS, I am trying to UPDATE one of my column on my table. The column itself is called 'center_point' with type of GEOGRAPHY(Point,4326) UPDATE cities SET center_point = ...
3
votes
1answer
207 views

Spatial query, embed in layer or project

I have 2 vector layers: 1) Polygons with parcel-boundaries 2) Polygon with project-boundaries I want to query all the parcels that are within the project-area, using spatial query 'select parcels ...
3
votes
2answers
735 views

Spatial query that doesn't seem to work

I have QGIS 2.8.2 Wien on windows 7 and quite new to QGIS. I have two shapefiles - 1 with rivers and 2 with sites located on some of those rivers. I want to carry out a spatial query to find the river ...
3
votes
1answer
149 views

Addresses within radius of vector layer in QGIS

I want a CSV file of all addresses that intersect with historical stream features. Currently, I have 3 datasets (see my blog) for this in QGIS 2.16.3 (MacOSX): a layer (.gdb) of historical stream ...
3
votes
1answer
4k views

Problem PostGIS Spatial Query ST_Contains ST_Disjoint ST_Intersects

I'm working on a project with two different tables inside a database. One contains points in a column geometry(Point,4326) type and the second one has a column geometry(MultiPolygon,4326). Now I would ...
3
votes
1answer
1k views

Finding polygons inside polygons from a shapefile in QGIS

I have a parcels shapefile that contains polygons. Condos are also drawn, but inside the master lot. I want to be able to grab all the condos inside the master lot. I saw this question/answer: ...
3
votes
0answers
43 views

Symbolize thousands of polygons to identify similar geometries

I would like to categorize polygons with a similar enough geometry so such similarities can identified at a city-wide scale. I'm trying to identify if street layout is a useful spatial characteristic ...
3
votes
0answers
45 views

QGIS Spatial Query Providers Issue

During the tutorial : http://www.qgistutorials.com/en/docs/performing_spatial_queries.html I have a error message like below. [ What is the providers mean? I really try to figure it out but ...
2
votes
3answers
2k views

drawing concentric circles in arcmap 10.1

I am using ArcMap 10.1 and I would like to know if there is a way to draw circles at a specific distance from a georeferenced coordinate. I have a property and I would like to know how far you can ...
2
votes
2answers
274 views

Comparing and find out which feature has highest shape area in QGIS?

I need to find out which polygon is having more area by filtering unique ID. the problem is I have 1000 of features which I need to find out highest occupied area for every unique value... since I ...
2
votes
1answer
1k views

Postgis using st_geometry linestring on column

I'm trying to create a linestring based on a value in a column in PostGIS. My code looks like this: create view left_span as SELECT st_geomfromtext('LINESTRING(line_att.wkt_left)', 27700) as geom ...
2
votes
2answers
1k views

vb.net arcobjects spatial query get fields value of desired layer only

Currently I am using ArcObjects (10.2.1) in vb.net (vs 2012). What I intent to develop is a spatial query tool. There are 2 steps in the function: (1) Use "Select Features" tool in ArcMap to select ...
2
votes
1answer
744 views

ST_Contains for 3D geometry

I want to query which ward contains the most cycle stations (a cycle station is a 3D geometry i.e. polyhedral) - the wards are 2D polygons - below is what I have worked out so far - The error I get ...
2
votes
1answer
203 views

query with buffer

I have 2 points layers. One contains old address points and the second has new address points. They don't have any unique attribute with which I could join them. So, I've made a 10 metre buffer ...
2
votes
2answers
150 views

Detect the point that lies inside line containing area

I have Two layers one is point another is line as indicated in picture. I want to know they way that i can detect that point is contains/intersect/near to the line so that I can add it's attribute ...
2
votes
2answers
66 views

How do I precisely select lines within a polygon in QGIS?

I want to select lines (bahnstrecken) within a polygon (bundesland). My goal is a selection shown in the following screenshot, which I did manually. Before I used two tools: I converted the polygons ...
2
votes
2answers
72 views

ArcGIS - Selecting features depending on 2 attributes

Ok, I guess this should be not too hard, but I can't figure it out: I have a layer "A" resulting from a layer "0" which was intersected with itself. So layer "A" contains all intersects. The ...
2
votes
3answers
740 views

What are the coordinates on my rectangle of the closest point to a polygon in R?

I have a non-overlapping extent rectangle and a sample lake polygon. I can measure the distance from the rectangle to the polygon but I want to know which point on the rectangle is the closest to the ...
2
votes
1answer
540 views

Find nearest point given coordinates from another table [duplicate]

So I have two tables, one table is called stores which has the name of the store as well as the geom column that contains the coordinates for the stores. The other table is customers which has the ...