New answers tagged

0 votes

Merging two polygon features (GeoJSON file) using QGIS

Multipolygon is an array of polygon coordinates. So you'll need to wrap the coordinates in another array. Try this: { "type": "Feature", "properties": { "id&...
user avatar
1 vote

Selecting only one point in polygon using QGIS

You don't need to write a script, there is a built-in Random selection within subsets tool. Before start you need to join by location ID of the polygons to your point data and specify that field in ...
user avatar
  • 5,642
3 votes

Selecting only one point in polygon using QGIS

To add even more performance improvements to @MrXsquared's answer by using QgsGeometryEngine and skipping feature fetching: point_lyr = QgsProject.instance().mapLayersByName('points')[0] poly_lyr = ...
user avatar
0 votes

Enlarging gBuffer width changes polygon shape

The gBuffer function needed a joinStyle = "MITRE" argument.
user avatar
  • 9
2 votes
Accepted

Splitting feature into individual features in QGIS

Use Multipart to Singlepart Splits multipart features in the input layer into singlepart features. From one multipolygon to 2786 single part polygons:
user avatar
  • 51.4k
6 votes

Selecting only one point in polygon using QGIS

With the "Select by expression" tool you can use: array_first( array_agg( $id, group_by:=overlay_intersects('polygons', $id), -- replace 'polygons' filter:=...
user avatar
4 votes

Selecting only one point in polygon using QGIS

To add some performance improvements to @Ben W's answer by using a spatial index and a break command: point_lyr = QgsProject.instance().mapLayersByName('points')[0] poly_lyr = QgsProject.instance()....
user avatar
8 votes
Accepted

Selecting only one point in polygon using QGIS

If you don't care which point is selected, you can use this small PyQGIS script. Paste into a blank editor in the Python Console, change the layer names in the first two lines to match your layer ...
user avatar
  • 13.6k
5 votes

Selecting only one point in polygon using QGIS

One way to do it would be: First do a "Join Attributes by location" (Vector -> Data Management Tools) with your points as the Base Layer, your polygons as the Join Layer, "within&...
user avatar
  • 156
3 votes

Deleting small holes in polygons with PostGIS

Based on dr_jts response, I propose the following version of the design and name of the new spatial SQL function: Create a spatial custom SQL function: CREATE OR REPLACE FUNCTION ...
user avatar
0 votes

ArcGIS clip raster with polygon - keep only cells that are fully within the polygon

This can be done after masking out conflicting cells at boundaries of polygons. So set sell size and snap raster to original raster and: PolygonToLine_management("POLYGONS", "in_memory/...
user avatar
  • 21.4k
0 votes

ArcGIS clip raster with polygon - keep only cells that are fully within the polygon

I think the issue here is that your polygons are captured using a different technique (e.g. manually captured) and scale so they don't align with the raster cells. Here is a simple model that will ...
user avatar
  • 38.5k
7 votes

Deleting small holes in polygons with PostGIS

Just to add a little less convoluted solution in SQL, shifting construction logic to ST_BuildArea - the LATERAL join predicate is an elegant method to expand and iterate over sets of rows returned ...
user avatar
  • 23.3k
13 votes
Accepted

Deleting small holes in polygons with PostGIS

This is one of those processes which are simple in an iterative language, but trickier in set-oriented SQL. But the ST_DumpX set-returning functions in PostGIS and the array handling in Postgres make ...
user avatar
  • 3,621
3 votes

Deleting small holes in polygons with PostGIS

Based on your example, just extract the interior ring of your geom, calculate it's area and use it as condition in where clause as: SELECT gid, ST_Collect(ST_MakePolygon(geom)) As geom FROM ( ...
user avatar
  • 423
1 vote

Clip Line Layer to Polygon but retain the Lines outside the polygons

If your aim is to only keep the lines that do not intersects the polygons you could use the "extract by location" tool. Layer to select from : your line layer Additional layer : your polygon ...
user avatar
  • 1,439
3 votes

How to get a list of lines, with a list of polygons that they intersect?

This is generally solved using an [INNER] JOIN, or if you are also interested in lines that do not intersect any grid cells in the result set, a LEFT JOIN; you then want to GROUP BY your line_ids and ...
user avatar
  • 23.3k
1 vote

Unable to join data from another layer

If you want to join attribute data of one layer to other then you should use "Joins and Relates". Run the join command with "Join data from another layer based on spatial location"....
user avatar
1 vote

Unable to join data from another layer

If you only need the attribute table from one layer to another, "join attributes by location" function with "intersect" geometric predicate, should work. If each feature has it's ...
user avatar
5 votes

Rotating by 90° one and more polygons in QGIS

Try the "Rotate" tool. Rotates feature geometries by the specified angle clockwise. The rotation occurs around each feature’s centroid, or optionally around a unique preset point. Also ...
user avatar
  • 23k
1 vote

Extracting admin boundary data from OpenStreetMap

It depends how many boundaries you would like to extract from OSM. For single city shape osmnx would be easiest option. If you need to get admin boundaries for whole country, processing OSM data dump ...
user avatar
1 vote
Accepted

Split Polygon in one layer based on boundaries in second layer

In the processing toolbox search for Polygons to lines and convert Layer 2 into lines, then search again for Split with lines, use the lines that you have created to split Layer 1.
user avatar
  • 4,388
1 vote

Enabling "Snapping" in QGIS while drawing polygons?

In case anyone is wondering: you activated the snapping options when this toolbar appears.
user avatar
0 votes

Buffering polygons with Oracle Spatial 11 vs. 19

By the Oracle Spatial 12c documentation the buffer function creates arcs https://docs.oracle.com/database/121/SPATL/sdo_geom-sdo_buffer.htm#SPATL1111 but you can process the resulting geometry ...
user avatar
  • 51.5k
0 votes

Wrong polygons displayed in QGIS spatial query

There are 2 geometry column in your query, and the 1st one is used by default. You can remove it ("buffer 100m".geometry) or put it in 2nd, or declare the geometry column in the options ...
user avatar
  • 34.3k
5 votes

Selecting points which touch "boundaries" of another polygon using QGIS

You can use "Select by expression" via QGIS's Processing Toolbox (Ctrl+Alt+T) or attribute table (F6). Run it on your points layer and use this expression: distance( $geometry, ...
user avatar
4 votes

Selecting points which touch "boundaries" of another polygon using QGIS

Convert your polygons to lines Select by location, the buffers intersecting the lines (or Select within distance, your title says points but question body says polygons)
user avatar
  • 51.4k
0 votes

Split polygon by regard of distance to other shapefile

You can : create centroids of your buldings use Voronoi Polygons with those centroids clipped the polygons with the water surface If you also need the beach line, you can create the boundary of your ...
user avatar
  • 1,385
2 votes

Looking for GeoPandas equivalents of PostGIS "ST_DumpRings" and "ST_Dump" tools

Try either .interiors: Returns a Series of List representing the inner rings of each polygon in the GeoSeries. .exterior Returns a GeoSeries of LinearRings representing the outer boundary of each ...
user avatar
  • 23k
1 vote
Accepted

Read geo-spatial data in R via Leaflet

Here's a sample sp-class points data frame in a projected coordinate system like your data is: > ps class : SpatialPointsDataFrame features : 4 extent : 1, 4, 1, 4 (xmin, xmax, ...
user avatar
  • 51.2k
0 votes

Invalid geometry in QGIS vs ArcGIS

It could be that those programs on your machine are set with different defaults for rounding decimals. If one rounds to the 7th decimal and one to the 8th decimal then you may have occasions where ...
user avatar
0 votes

Counting stacked polygons in PostGIS

Let's assume there is a polygon layer called 'poly_test', see image below. Extending the idea from @geozelot it is possible to count the polygons via grouping by their geometry. With the following ...
user avatar
  • 23k
2 votes
Accepted

Joining two polygons where they overlap the most in QGIS

Let's assume there are two polygon layers one called 'grid_test' (green) and the second called 'grid_test2' (orange), see image below. Apply the "Join attributes by location" tool with the ...
user avatar
  • 23k
5 votes

Finding change between two sets of polygon data in QGIS

Run Menu Processing > Toolbox > Geometry by expression with this expression with Input Layer the polygon layer representing the boundaries in 2020. In the expression at the end of line 2, ...
user avatar
  • 40.1k
1 vote
Accepted

Create sf polygon from sf linestring and bounding box

I suggest using lwgeom::st_split() to split your counties object according to the coast linestring. It will return a geometry collection, so it needs to be piped to a sf::st_collection_extract("...
user avatar
3 votes

Joining two polygons where they overlap the most in QGIS

Use QGIS expressions with this expression: array_first ( overlay_intersects( 'Districts', -- Replace with the name of the layer $id, sort_by_intersection_size:='des' )...
user avatar
  • 40.1k
1 vote
Accepted

Using Shapely methods (explain_validity and make_valid) on shapefile

Two above method (explain_validity and make_valid) are applicable not to the shapefile itself, but to the objects (geometries of features) that it contains. To apply the explain_validity() method: ...
user avatar
  • 23k
1 vote

Looking for QGIS equivalent of ArcMap's "Selection by Location" tool with "Have their centroid in" option

You can use multiple steps: Create centroids of the layer you want to select from Extract the centroids within the selection polygon layer Extract the polygons intersecting the extracted centroids:
user avatar
  • 51.4k
0 votes

Using Shapely methods (explain_validity and make_valid) on shapefile

You need to control the validity of every geometry in the shapefile (= row in the geodataframe) for i in data.index: explain_validity(data.geometry[i])
user avatar
  • 50.8k
0 votes

Speeding up a TIN to MultiPolygonZ conversion in PostGIS

Atm was actually right in his comment. And indeed, it's actually a nonsense to tessellate a TIN! It was an error on my side. Here is a detailed comparison for a same query with and without the use of ...
user avatar
  • 6,698
0 votes

Converting Shapely MultiPolygon to Polygon: Technique doesn't always work

object.convex_hull is all you need Note: This object is can be a MultiPolygon
user avatar

Top 50 recent answers are included