Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 32958

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

4 votes

Automatic generation of attribute, taking the value from another layer in QGIS

Add a new field to the point layer, same type as the polygon field. Go to Layer Properties - Attributes Form - Drag and drop designer, drag the newly added field from Available Widgets to Form Layout …
Bera's user avatar
  • 77.8k
2 votes
Accepted

Creating point grid over polygon boundary in Python / geopandas

Find the total bounds (xmin, ymin, xmax, ymax), create two lists of x and y coordinates within them. List all combinations of the x and y coordinates, create points. import geopandas as gpd import num …
Bera's user avatar
  • 77.8k
3 votes
Accepted

Creating a dummy to identify if a point lies within a polygon using Python

Use spatial join import geopandas as gpd import numpy as np poly = gpd.read_file(r'D:\temp_diverse\polygons.shp') point = gpd.read_file(r'D:\temp_diverse\points.shp') df = gpd.sjoin(poly, point[['ge …
Bera's user avatar
  • 77.8k
2 votes
Accepted

Number of points in polygon not equal in QGIS and Geopandas

I get the same count in geopandas and QGIS. Your code is a bit complicated, try using groupby: import geopandas as gpd dfpoint = gpd.read_file(filename=r'/home/bera/Desktop/GIStest/1000points.shp') d …
Bera's user avatar
  • 77.8k
7 votes

Counting distinct values per polygon in QGIS

With SQL and a Virtual Layer you can try: select town, type, count(*) pointcount, geometry from pointlayer group by town, type
Bera's user avatar
  • 77.8k
3 votes

Counting points in polygon using separate attribute values in ArcGIS Pro

Intersect points with polygons Dissolve with statistics field unique: Unique—The number of unique values of the specified field will be counted
Bera's user avatar
  • 77.8k
4 votes
Accepted

Assigning point attribute to overlapping polygon in QGIS

Try: Join attributes by location Takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its attribute table.Takes an …
Bera's user avatar
  • 77.8k
4 votes
Accepted

Incompatible numeric format between points and polygons geometry in GeoPandas

Reproject so the dataframes are in the same crs: Transform all geometries in an active geometry column to a different coordinate reference system I want both in EPSG:4326: print(poly.head(2)) # 0 P …
Bera's user avatar
  • 77.8k
2 votes

Generating points inside MultiPolygons using GeoPandas

This is now very easy with .sample_points (see the Changelog Version 0.13 (May 6, 2023)) import geopandas as gpd df = gpd.read_file(r"/home/bera/Desktop/gistest/district.gpkg") ax = df.plot(figsize=( …
Bera's user avatar
  • 77.8k
2 votes
Accepted

Finding majority land use class within polygon in QGIS

You can use the expression: array_majority( array:=overlay_intersects( layer:='points', expression:="rasterval" ) )[0] It will create an array of all values in the co …
Bera's user avatar
  • 77.8k
6 votes
Accepted

Fetching and combining field values from vector layer to another in QGIS

You can use "Join attributes by location" tool: Takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its attribute ta …
Bera's user avatar
  • 77.8k
3 votes

Visualizing points with different colours based on field from polygon layer in QGIS

You can create a new field using Field Calculator to fetch the region name from the region layer. Then symbolize the point layer using the new field. Example: array_to_string(overlay_intersects('distr …
Bera's user avatar
  • 77.8k
7 votes
Accepted

Skipping invalid geometries without fixing them in QGIS

Try buffering your polygons with 0 distance, sometimes it fixes geometry errors. If you want to ignore the invalid geometries, you can set it Options - Processing - General:
Bera's user avatar
  • 77.8k
8 votes

Creating set number of regularly spaced points inside of polygon in QGIS

I use this pyqgis code to create a fixed number of sample plots in forest stands/polygons. It will create a point layer in memory. Click/highlight your polygon layer, adjust the number of plots below …
Bera's user avatar
  • 77.8k
4 votes

Giving specific naming of points within quadrant in QGIS

You can create a virtual layer. The query will calculate the azimuth from each polygons centroid to all intersecting points. Replace "centroids" and "grid" with the names of your layers: select pnt.*, …
Bera's user avatar
  • 77.8k

15 30 50 per page