Hot answers tagged

4

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


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....


3

The .area in shapely is plane area, so we need to transform longitude, latitude (4326) to project spatial reference (e.g. 3857). For rectangle, if the original size is a * b, area is A, buffer distance is X, the buffer area B then: B = A + 2 * (a + b) * X + pi * X * X ----- (1) 2 * (a + b) = c = perimeter = poly_B.length (1) => X = sqrt(c * c - 4 * (...


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): ...


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

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


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::...


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)["...


2

If you're using QGIS, and all you want is the highlighting, you can use the layer styling on your DEM layer to very easily achieve your highlighting. See screenshot below: set Render Type to Singleband pseudocolor set Mode to Quantile, and delete entries until you get three bands set the value field of the first two bands to the top and bottom numbers of ...


2

The problem is that your central meridian is 0 degrees (greenwhich). russia e.g. goes "beyond" 180 degress east of greenwich. you can find a solution for this problem here: How to dissolve naturalearth vectordata with gdal?


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 ...


1

R thinks one or more of your polygons are holes, and a hole has to be inside a non-hole. Hole detection is done in the Polygon function: Polygon(coords, hole=as.logical(NA)) coords: 2-column numeric matrix with coordinates; first point (row) should equal last coordinates (row); if the hole argument is not given, the status of the ...


1

If you want to have that information in the attribute table, try the aggregate function. Some examples here https://spatialthoughts.com/2019/04/12/summary-aggregation-qgis/


1

Read again the documentation of the GDAL GeoJSON driver https://gdal.org/drivers/vector/geojson.html and modify your command to produce GeoJSON that follows RFC 7946 by adding a layer creation option -lco RFC7946=YES. Excerpt from the documentation: RFC 7946 write support By default, the driver will write GeoJSON files following GeoJSON 2008 specification. ...


1

"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


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 ...


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


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 ...


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 ...


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)): ...


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


Only top voted, non community-wiki answers of a minimum length are eligible