New answers tagged

0

"Dissolve" is the tool you're looking for. You can also use the plugin "Dissolve with stats" if you want to calculate the sum of subspecies within a main basin for example. EDIT: you have also the "Agregate" tool


2

An approximation since it will only measure distances between existing vertices: import geopandas as gpd from shapely.geometry import LineString, mapping from itertools import combinations import re df = gpd.read_file('/home/bera/GIS/Data/testdata/longest_line2.shp') longest_lines = [] for g in list(df.geometry): all_coords = str(mapping(g)["...


1

Union the polygons with themselves: Then adjust and execute code below. It will find the duplicate geometries produced by Union and store their count in a field: from collections import defaultdict lyr = iface.activeLayer() #Click union layer feats = [f for f in lyr.getFeatures()] opcount = defaultdict(list) processed = [] for i in range(0,len(feats)): ...


3

The following function (adapted from here) receives a polygon geometry and gives you a QgsMultiLineString with all polygon rings. It takes into account single and multi-parts. def get_polygon_rings_as_lines(polygon): # Input polygon can be multi or single part # and could have interior rings def get_rings_from_polygon_part(part_polygon): ...


0

There is my work in progress code. #BinarySearch - Visibility name1='ObservationPoints' name2='Added' name3='line' layer1 = QgsProject.instance().mapLayersByName(name1)[0] layer2= QgsProject.instance().mapLayersByName(name2)[0] #layer3=QgsProject.instance().mapLayersByName(name3)[0] #initialise variables pi=0 #first initial observation point pn=((layer1....


1

The info you are missing is that you have access to clicked polygon feature properties from event property e.layer.feature.properties. So in your case event processing function could look something like this (note that because of Leaflet [lat,lng] coordinates order GeoJSON marker coordinates have to be swapped) : polygonGroup.on('click', function(e) { var ...


4

You have to prevent propagation of click event once you catch it in featureGroup layer. Leaflet has handy method L.DomEvent.stopPropagation just for that (see https://leafletjs.com/reference-1.6.0.html#domevent). In your case code would look something like that: featureGroup.on('click',function(e) { console.log('clicked on polygon'); L.DomEvent....


0

Further to the above answer of 0 buffer distance - this didn't work for me, HOWEVER I will give credit to the author for leading me down the right path. I actually ended up applying a 1mm buffer and dissolving the result. I would recommend dissolving as a secondary step, because you may wish to apply different dissolve parameters (as opposed to using the '...


0

I know I'm late to this answer, but since I came across the same problem, this is how I solved it. Download and install the MMQGIS plugin, then in the menubar select MMQGIS>Combine>Spatial Join In the popup window select the municipalities as the target layer and the climate layer as the join layer. Select the climateID as the join field then select '...


3

I tried to use derived formula in Math SE answer but it was not possible. I think there is an undetected error in its demonstration. However, you have an obvious answer in your image: Distance for moving blue rectangle (assuming height > width), independent of any rotation angle, is always X. It is easily calculated as intersect length of green dotted ...


2

No plugin needed In addition to the Shape Digitizing Toolbar it's also possible to add right angles through the Advanced Digitizing Tools. Activate the Advanced Digitizing Tools and lock the angles to 90° . Have a look at the documentation of the advanced digitizing tools for what else is possible. With QGIS 3.14 the last missing bit was added and it is now ...


0

I have downloaded the 1.5 GB shape file called MAMMALS for testing. There was one invalid polygon, which was easy to validate. Now the issue with this layer is that for Union, and most other analysis alike, it has way too complicated polygons which will be hard to process in reasonable time on local desktop. This leads me to suggest quick and dirty solution -...


1

Despite a brilliant answer from @ahmadhanb, I would like to share an idea of how to invert a filling of polygon with Geometry Generator. Let's assume that there is a polygon, shown on the Picture beyond. Use the following setting for the Geometry generator and get the result, see image below


-1

use: pip install python-geohash instead of pip install geohash


1

Your proposed procedure would work if you are willing to accept an approximation, since there is no guarantee that your one of your radial bearing lines is the true longest line. It's also horribly inefficient. A slightly better procedure would be: For each observation point Pi, draw the line to Pi + 1, Pi+2 until the line crosses the boundary. Let's say ...


2

A recipe for your intent (deduced from answer Qgis 2.7 (Dev) feature rotation?) rotation = 45 vlayer = iface.activeLayer() provider = vlayer.dataProvider() couples_id_geom = [] for feature in vlayer.getFeatures(): geom = feature.geometry() centroid = feature.geometry().centroid().asPoint() geom.rotate(rotation, centroid) # accumulate args to ...


2

So my colleague came up with this solution. It works great for small areas, but I'd like to find a solution for millions of shapes across an entire country. I can see the ST_UNION here causing a blockage in this respect. The ST_BUFFER is just to close out thin slithers. SELECT ST_DIFFERENCE(foo.geom, bar.geom) FROM (SELECT ST_CONVEXHULL(ST_COLLECT(shape::...


4

The "Join Attributes by Location" algorithm from the Processing Toolbox has a switch to do exactly this:


1

this code will fill the gaps and holes in the polygons. adjust according to your data SELECT id, ST_Collect(ST_MakePolygon(geom)) As geom FROM ( SELECT gid, ST_ExteriorRing((ST_Dump(geom)).geom) As geom FROM layer ) s GROUP BY id


2

In qgis there is a plugin called select by centroid. But building on that I developed my own model to join based on the layer centroids by converting the layer to centroids and then join that table... Works a treat


0

You can: 1: Union to generate all possible geometries 2: Compare all geometries using .equals and keep the one with highest priority 3: Dissolve and Multipart To Singelpart from itertools import combinations layer_to_process = QgsProject.instance().mapLayersByName('Polygons')[0] #Change Polygons to match your layer name prio_fieldname = 'prio' #1 is kept ...


0

I try to give you a solution using a sample data set of three polygons. Polygons have a unique ID and a PRIORITY columns. (polygon fill is 50% transparent to see the overlapping parts). Convert the polygons to lines (we'll use these lines to split the polygon layer) using Vector/Geometry Tools/Polygons to Lines... from the menu. You'll get layer Lines ...


1

This is a link to the National States Geographic Information Council's zip code database. It should have what you need. https://catalog.data.gov/dataset/zip-codes-zipcodes If it doesn't this site has a paid zip code database (which is free for personal use) https://www.unitedstateszipcodes.org/zip-code-database/ Keep in mind though, a large part of the ...


-2

for ring in poly.interiors: pol = Polygon(ring) if(pol.area < maxAreaTh): poly = poly.union(pol.buffer(0.3)) return poly


5

This task can be done using difference. Set the line layer first, the polygon second, then the polygon area will be substracted from the lines and you have your desired result. A bit of genereal advice: If a tool "does nothing", there are several option. Maybe the tool really doesn't work, maybe your layers are faulty, or maybe the user did ...


7

In processing toolbox, search for overlap analysis and you will find the tool that will do what you want: From the tool help: This algorithm calculates the area and percentage cover by which features from an input layer are overlapped by features from a selection of overlay layers. New attributes are added to the output layer reporting the total area of ...


0

This is a process of three steps: Run intersection: The first input layer are you black circles, the second one is your landuse (the whole layer). This gives you a layer with the extent of the circles and the properties and division into categories of the landuse data. Run dissolve based on the landuse. Use the field calculator to calculate the $area of the ...


0

Convert the shapefile to .kml layer first then use dissolve. After dissolve, you can then convert the kml layer back to shp. Worked for me.


2

I'm using [...] EPSG4326 there's your problem. This CRS is based on degree, so any distance/area calculations you do on this layer are done in degree, too. Save your layer to a CRS based on meters, which fits your area of interest, then do the calculations.


Top 50 recent answers are included