New answers tagged

0

Following the clues given in @RomaH's answer, I think I've got what I wanted, using a subquery: with cte as (select m.utmcode utm, c.code_18 code, round(Sum(st_area(st_intersection(m.geom,c.geom)))/10000) area from public.malla m left join public.clc18 c on st_intersects(m.geom,c.geom) group by utm, code) select utm, MAX (CASE WHEN code = '111' THEN &...


1

You can use spatial join: import geopandas as gpd df1 = gpd.read_file(r'/home/bera/Desktop/gistemp/greens.shp') df2 = gpd.read_file(r'/home/bera/Desktop/gistemp/buildings.shp') df2['savedindex']= df2.index #Save the index as a column intersecting = df1.sjoin(df2, how='inner')['savedindex'] #Find the polygons that intersect. Keep savedindex as a series ...


1

You can do the following: new_df1 = df1.loc[~df1.intersects(df2.unary_union)].reset_index(drop=True) The new_df1 GeoDataFrame will contain all the observations/rows/features from df1 that DO NOT intersect with the elements of df2.


1

I think what you are wanting can be accomplished by a pivot. This SO post question covers it quite well. https://stackoverflow.com/questions/69263964/how-to-pivot-in-postgresql This can be accomplished through your select statement by specifying a filter for each Corine types you want to see. As the statement is executed each record is checked against the ...


6

This is a consequence of sf now working with spherical geometry by default. The real straight line between the two top corner points of your rectangle are great circles, which will be bulging north. Switch that off and sf will assume lat-long is planar and you get the result you expected: > sf_use_s2(FALSE) Spherical geometry (s2) switched off > ...


2

Here is an example of how this can be done. Replace the values of the first four variables to match your use case: # -*- coding: utf8 -*- from qgis.PyQt.QtCore import * from qgis.PyQt.QtGui import * from qgis.PyQt.QtWidgets import * from qgis.utils import iface from qgis.core import * import processing layers = [layer for ...


1

The speed difference is likely due to QGIS using GEOS backend and the current stable sf (v1.0 plus) using s2 library from Google; for more information consider official documentation https://r-spatial.github.io/sf/articles/sf7.html The s2 library / package introduces a new dimension to intersections - the concept of a model. In the default behaviour (model = ...


2

Another approach is to use the "Extract by expression" geoalgorithm together with the following expression: overlay_intersects(@layer) it uses the overlay_intersects() function. Input: Algorithm's window: Output:


4

Union the layer with itself Extract by expression "fid"<>"fid_2", replace fid with whatever id column you have.


1

You can create a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... Replace polylayer with the name of your polygon layer and idcolumn with the name of your id column (create one if you don't have one): SELECT ST_INTERSECTION(a.geometry, b.geometry) FROM polylayer a, polylayer b WHERE a.idcolumn < b....


2

Let's assume there area two layers, a polygon layer 'layer' and a polyline layer 'lines_test', see the image below In the polygon layer create a new field "NewId" using Field calculator with the following expression: with_variable( 'lines', 'lines_test', -- name of the polyline layer array_find( array_agg($id, ...


0

I think the best way to do this is to add vertices to your line (for example every 2 meter) and then with python you can loop over the vertices and check for intersection with the parcellayer. If there is intersection, then you write the value of the counter (starting with 1) to a field of the intersected parcel. Next you check for the following vertex and ...


4

You don't need to define a new method to get the intersected line. QgsSnappingUtils class has snapToMap() method which returns a QgsPointLocator::Match struct and it has featureid() method which returns the snapped feature id. Then, you can get the feature by id. Use like this: class AddPoint(QgsMapToolEdit): def __init__(self, canvas, iface, layer): ...


4

To get the count of all UTM-features that intersect with the current National Park feature: aggregate( layer:='UTM', aggregate:='count', expression:='COD1X1', filter:=intersects($geometry,geometry(@parent)) ) To count all UTM-Features that intersect with all National Park features: aggregate( layer:='UTM'...


1

You didn't say the reason of your affirmation related to "after several failed attempts". So, I supossed that it was in the impossibility of exporting intersectJoined Feature Collection as shapefile. This collection has the unusual field (Property) id whose content is a List type Object; producing an error code 3 when it is trying to export as ...


Top 50 recent answers are included