Questions tagged [point-in-polygon]

A common GIS operation. Used to determine whether a point lies within a polygon's bounds.

Filter by
Sorted by
Tagged with
54
votes
2answers
107k views

Selecting features within polygon from another layer using QGIS

I'm using QGIS 1.8 with a PostGIS database and I have three PostGIS layers in QGIS a lines layer, a points layer, and a polygon layer. I'm trying to select features in the polygon layer and mark all ...
38
votes
10answers
11k views

Creating regular point grid inside polygon in PostGIS

How to create, inside a polygon, a regular grid of point spaced x,y in PostGIS? Like the example:
36
votes
4answers
30k views

Overlaying spatial polygon with grid and checking in which grid element specific coordinates are located using R [closed]

How can one use R to split a shapefile in 200 meter squares/sub-polygons, plot this grid (incl. ID numbers for each square) over the original map below, and evaluate in which square specific ...
35
votes
2answers
16k views

Looking for fastest solution for Point in Polygon analysis of 200 million points [closed]

I have a CSV containing 200 million observations with the following format: id,x1,y1,x2,y2,day,color 1,"-105.4652334","39.2586939","-105.4321296","39.2236632","Monday","Black" 2,"-105.3224523","39....
28
votes
3answers
45k views

Join spatial point data to polygons in R

I am trying to perform a spatial join between point data and polygon data. I have data that indicate the spatial coordinates of an event in my csv file A and have another file, shapefile B, that ...
24
votes
2answers
11k views

How can I find a point inside a polygon in PostGIS?

How can I find a point that is guaranteed to be within a given polygon in PostGIS? I am aware of the ST_Centroid function. However, the centroid is not always within a polygon, see below: ...
20
votes
2answers
16k views

Counting Points in Polygon with PostGIS

I've got a simple problem: I want to count the number of points within a set of polygons. I have a SQL already but it only gives back the gid of the polygone that actually contains points. My tables: ...
19
votes
7answers
3k views

Fastest way to spatially join a point CSV with a polygon Shapefile

I have a 1 billion point CSV file and a shapefile with around 5,000 polygons. What would be the fastest way to spatially join points and polygons? For each point, I need to get the containing polygon ...
18
votes
2answers
17k views

Converting cluster of Points to Polygons using QGIS

I have an input point layer that is grouped into clusters, so I want to have each cluster of points converted into polygon. This question How to convert a set of points to a polygon based on a ...
17
votes
3answers
70k views

Check if a point falls within a multipolygon with Python

I have tried several examples of code using libraries such as shapefile, fiona, and ogr to attempt to check whether a point (x, y) falls within the boundaries of a multipolygon created with ArcMap (...
12
votes
1answer
8k views

Updating field to give count of points in polygon using STIntersects?

I have a points layer (dbo.ptLayer) Around 1M points Spatial Geometry Type (dbo.ptLayer.geom) No spatial index just yet, but will create one once data gathering complete. I have a polygon layer (dbo....
12
votes
3answers
17k views

Getting point attribute from polygon layer using QGIS

In QGIS I have two layers: (A) has point features and (B) has polygons. How do I produce a new table with some (the "ID") or all the fields from the 'A' table and some (the area code) or all ...
12
votes
1answer
561 views

Spatial operators in R?

How can I do spatial selections or filters in R? I can do this in PostGIS using (e.g.): SELECT * FROM mypoint, mypoly WHERE ST_Within(mypoint.geom, mypoly.geom); and it is similarly a piece of cake ...
12
votes
2answers
4k views

How does spatial polygon %over% polygon work to when aggregating values in r?

I'm working on an environmental epidemiology project where I have point exposures (~ 2,000 industrial hog operations - IHOs). These IHOs spray on nearby fields, but the feces water droplets and smell ...
11
votes
3answers
5k views

Point in polygon algorithm for multiple polygons

I've a Google map with bunch of polygons on it. Here is a problem I'm interested in: Given a lat,lng point, what's the best way to determine all the polygons that this point lies in? The obvious way ...
10
votes
1answer
7k views

Counting points in polygons using QGIS

I want to count points (1000 of students home) in district polygons with Qgis 2.16. I didn't find the tool in the analysis tools plugin. Is there another plugin or method I could use to perform this ...
10
votes
1answer
3k views

Performance Gain Through GIST Index for Point in Polygon Query

I have two tables: locations(id,region_id,the_geom) and regions(id,the_geom). For each location point I want to determine the region it is located in: UPDATE locations SET region_id = (SELECT id ...
10
votes
2answers
2k views

Update database row with points that fall within polygons

I have a PostGIS/Postgresql DB that has two tables in it. One with point geometries and the other that represents country boundaries as polygons. I would like to add the country name that each point ...
10
votes
2answers
3k views

Counting number of features within another feature using aggregate function in the QGIS Field calculator

My data: 1 polygon layer + 1 point layer My target: Calculate the number of points and the sum of a field within each polygon using the aggregate function in the QGIS field calculator. I know I can ...
10
votes
1answer
13k views

How to find points within a polygon in PostGIS

I have a series of lat and long coordinates I've loaded into a spacial table (Nov01) in PostGIS, and I've created a geometry column in the table. I also have a shapefile (greatermanchester) I've ...
9
votes
3answers
313 views

Adding new field in point layer with attribute from another layer in QGIS

I'm working with QGIS 3.16 Hannover under MacOS 10.13 environment. I've got a point and a polygon shapefile layers. I want to add a new field to my point layer with the "id" of the polygon ...
9
votes
4answers
57k views

Check if lat/long point is within a set of polygons using google maps

I know how to do the above using Esri (Query task on shapefile), but can this also be done using Google Maps? Do I have to query each polygon or is there one method to query a set of polygons?
9
votes
3answers
1k views

Creating large amount of random points in binary raster?

I want to create a point vector dataset of 10000 points (or larger) within a binary raster, where the points should be constrained to areas where the raster value is 1. I tried the following steps. ...
9
votes
1answer
1k views

Optimising a very large point in polygon query

I have a national dataset of address points (37 million) and a polygon dataset of flood outlines (2 million) of type MultiPolygonZ, some of the polygons are very complex, max ST_NPoints is around 200,...
8
votes
4answers
7k views

Looking for GeoPandas QGIS equivalent of ArcGIS "Select by location" tool

I have two GeoDataFrames: A single multi-part polygon Many points I have read them in with the following: import geopandas as gpd poly = gpd.read_file('C:\\Users\\srcha\\Desktop\\folder\\poly.shp') ...
8
votes
3answers
174 views

Selecting and exporting points inside specific polygon using QGIS

I have a problem that is similar to Get Points in a selected polygon. I have a polygon layer (with +200 features) that represents a road (subdivided by every 100m) and a point layer of a GPS survey ...
8
votes
1answer
3k views

Using 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 this Error: Wrong number of parameters. Here is my ...
8
votes
1answer
26k views

Shapely unable to tell if polygon contains point

For an application I want to determine under which constituency a given coordinate falls. After looking at the various options, I decided upon shapely and fiona as the easiest way to implement this. ...
8
votes
2answers
417 views

Generate points in multiple features taking minimum distance into account

I have a function which creates Wind Turbines represented as points. Essentially, it uses the code from the Random points inside polygons (fixed) tool albeit with some slight changes. The goal is to ...
8
votes
2answers
7k views

Total of attribute field of point layer per polygon layer

I have a polygon shapefile of many lakes, I also have a point shapefile of locations on those lakes where fish were caught. The point shapefile contains the attributes: Fisherman_iD, Fish_Caught, Lat,...
8
votes
3answers
6k views

Creating evenly distributed points within an irregular boundary

I need to create an evenly distributed series of points within a series of oddly shapped polygons (formerly squares, but now squares with donut holes). The way I have solved this problem so far is to ...
7
votes
2answers
2k views

Boundary from Points

I have a point cloud and need to process a very detailed boundary around the outer points. Is there a tool in QGIS? Convex hull is not detailed enough.
7
votes
1answer
544 views

Count points in polygon grouping by attribute using PyQGIS

I have a point layer with an attribute table like this: id_point class 1 A 2 B 3 A 4 C 5 B ... What I need is to count how many points of ...
7
votes
2answers
8k views

Point-in-polygon using Python and OGR

I want to use OGR in Python to write a simple point-in-polygon test: def point_in_polygon(point, polygon): """ point : [longitude, latitude] polygon : [(lon1, lat1), (lon2, lat2), ..., (...
6
votes
1answer
926 views

How to determine optimal windmill placement to maximize production?

How can I add automatically the maximum number of points (dots) with 6m diameter and 100m distance each point from other into an area. The dots will present the windmill base (6m) and I want the ...
6
votes
2answers
2k views

Creating polygons from one to many relationship of points using QGIS or PostGIS?

I have a set of polygons that are in a one to many relationship with points. The polygons are administrative boundaries and the points have information on companies and percentage of ownership . I ...
6
votes
2answers
14k views

Createing polygon layer from point data using QGIS?

I'm currently using QGIS 1.8.0 I would like to create a polygon layer from a point dataset, where the size of the polygons relates to the resolution of the grid reference. The ultimate aim would be ...
6
votes
1answer
3k 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),...
6
votes
2answers
8k views

Checking if Lng and Lat fall inside polygons from ESRI Shapefile

I have two input files. First: CSV file with a list of points each defined with Lng, Lat, Name Second: ESRI Shapefile defining a number of polygons I would like to determine for each point I have (...
5
votes
3answers
3k views

How to identify feature vertices that are part of a donut hole in ArcGIS 10?

I´m exporting the coordinates of polygon vertices to a CSV-File using the "Feature Vertices to Points" and then the "Export feature attributes to ASCII" tools. Some of these polygons have holes (...
5
votes
1answer
15k views

How to find points inside each polygon in Mysql?

I have points table (with latitude and longitude columns) and polygons table with geometry stored in Mysql. I want to get points inside one polygon, for example in polygon which has column name="...
5
votes
2answers
479 views

Calculating point layer values within polygon features in QGIS 2

There are two layers polygon 'BereichBerechnung' with a field "Are_Number" points 'EW2017' with a field "EWjeAdr" In QGIS with a Virtual Layer, I want to calculate the sum of the ...
5
votes
1answer
251 views

Preventing labels from overlapping certain features using QGIS

I have two layers in my QGIS Project (QGIS 3.4.8). One in the foreground, which contains surfaces, and one in the background, which contains a point with labels, see image below: The problem is that ...
5
votes
2answers
3k views

Combining st_join with st_nn to include all points within, as well as within a given distance of a polygon

This is a follow up to my earlier question (Spatial join in R - Adding points to polygons with multiple corresponding points). I have successfully joined a spatial points file to a polygon file in R ...
5
votes
1answer
195 views

Referencing a polygon layer in the field calculator of a point layer to make a virtual field

I have a polygon layer that shows the counties of England and a point layer of project sites. I am trying to make a new virtual field within the point layer that will reference the county that it is ...
5
votes
1answer
3k views

How to create randomly points within polygons for each row of a dataframe matching a Polygon ID with R

My question is similar to this post, but because there are no "perfect" answer and above all no reproducible example I open this question. I have a "SpatialPolygonsDataFrame" and a data frame. Both ...
5
votes
3answers
1k views

Does anyone know a function to determine if a Point lies on a polyline?

ArcEngine 10 .Net 4 c# I'm currently allowing user to select a point on a polyline and creating a point on the line. I am using snapping tool. I just want to make sure that when the user clicks on ...
5
votes
1answer
103 views

Equal distribution of points to regional hubs in QGIS

I have approximately 1,600 points plotted on a layer in QGIS. On another layer, I then have 8 regional hubs plotted. I am trying to distribute the 1,600 points among the 8 hubs, based on which hub ...
5
votes
1answer
181 views

Where is the "input point vector layer attribute" in the "Count Points in Polygon" in QGIS 2.18.9?

In older QGIS versions the Count Points in Polygon vector analysis tool had an "input vector layer attribute to aggregate" to perform a statistical analysis (sum, mean, min, max) on the counted points ...
5
votes
1answer
242 views

Which polygons surround this point? A practical case of political geography

I'm starting a project from scratch but am budget constrained. In plain language I've got no money. What I want is to provide an address and return what governments have jurisdiction there. The ...

1
2 3 4 5
8