Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged


Tested on QGIS 2.18 and QGIS 3.4 I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... Let's assume we have 10 features in "buildings" and 16 in "roads" accordingly, see image below. With the following Query, it is possible to find out the distance between a given building e.g. WHERE b.propertyid = '1' and the ...


An alternative approach would be to convert the building polygons to lines, or nodes. Then multi buffer the roads, probably in increments of 1 metre. Spatial join the two files and export the attribute table to Excel. That way you could select the closest wall of a building. Bit of a clunky method, but is one way of handling large buildings.


For qgis 3.8 and later you can use "join by nearest" from the processing toolbox.


While in general this would be better handled in PostGIS, there are plug-ins which do the heavy lifting for you: NNJoin MMQGis Hub Distance. NNJoin This is the preferable and correct way, however could be slow on large datasets. It has the non trivial advantage to compute the correct polygon-to-line distance, without converting buildings into points ...


Here's how to do this in the Python console or scripting - using the interpolate method: # Select the source - in this case the selected layer layer = iface.activeLayer() # Iterating through the features for f in layer.getFeatures(): # Get the geometry and interpolate the position at a distance (500) xy = f.geometry().interpolate(500) print(xy)...


Do your layers A and C just have NA where they don't have a value? i'd suggest using raster::distance. Just run separately for rasters A and C and merge (if relevant) Here's a dummy for you, ncells = 1 million, using an extremely crude boundary line; require(raster) # make 2 rasters (your A and C), with generic values r1 <- raster(xmn=0, xmx=1000, ymn=...


Using NUTS-3 centroids with the Near (Analysis) tool, the geodetic distance between the Shetland Islands and Jersey was calculated to be 1191878.03 meters. Using a Euclidean distance after projecting to British National Grid (with the default datum transformation), those two points are 1191362.07 meters apart (a delta of 515.96 meters, or 0.043 percent). ...


The API says measureLine is expecting QgsPointXY. point1 = QgsPointXY(474828.85, 6756169.31) point2 = QgsPointXY(874895.75, 6756159.5) distance = QgsDistanceArea() m = distance.measureLine(point1, point2)


This method expect point in latitude/longitude. Your coordinates are projected, so you can just do point1 = QgsPoint(474828.85, 6756169.31) point2 = QgsPoint(874895.75, 6756159.5) distance = point1.distance(point2)


If you have the Spatial Analyst extension, you could use the Flow Length tool to create a flow length raster. Then calculate the difference between the flow lengths of each pair of points based on which cell of the flow length raster they coincide with. (Of course you would need to be sure that both points in the pair are on the same stream).


It looks like a bug and/or improper projection. Using distances in long-lat degrees (which doesn't mean much), the result is the proper one. Using true ground distances (in meters), the reported distances are the proper ones. with src as (select 1 as id, st_makepoint(-2.92391,43.25722) as geom), dest (id, geom) as (values (2, st_makePoint(-3.36708, 40....

Top 50 recent answers are included