On the layer that is on top, add a new symbol layer of type Geometry generator (see documentation) / Point. Use this expression to generate the point from the other layer that is closest to the current feature:
Set the same settings for size. To avoid the larger points from this symbol layer to cover your initial ...
Enable Snapping (1), use Select features (2) to select the features of the grid you want to move, Toggle editing (3), click Move Feature(s) (4) and shift the upper left point of the grid until it snaps to the point (5).
You probably use shapefiles to store your layer. To solve your issue, save the layer to a Geopackage.
Shapefiles do not support Datetime field types. See the QGIS documentation about Shapefiles:
Only Decimal number, Whole number, Text data and Date attributes are
See also this explanation.
Do yourself a favour and install the fantastic spreadsheet layers plugin (more infos here: https://github.com/camptocamp/QGIS-SpreadSheetLayers)
After installation you can easily import excel-spreadsheets:
Dont forget to set the appropriate Geometry columns for lat and lon:
you are done!
The first step was to make sure that the .csv file is formatted in a way QGIS recognizes the numbers as numbers and not as a text. The comma (,) decimal separator was not recognized by QGIS. I had to make sure that the .csv file used a dot (.) as a decimal separator. In my case I just used a text editor to replace all commas by dots.
The .csv file then ...
@Sangster answered to his own question:
The following has recovered the project so has been noted to
help others, but it does not identify or repair the original problem
so I am not marking it as the answer. Note that simply duplicating the
affected layer resulted in duplicating the problem too.
To recover from this problem:
Right click the affected layer ...
There's another way to do that and you can use the year attribute from the CSV for setting the color.
Create the line by adding an additional symbol layer of type Geometry generator and create the line with this expression:
geometry (get_feature_by_id (@layer, $id)),
geometry (get_feature_by_id (@layer, $id+1)))
You can then set year as ...
On the centroid layer, you can use the following expression with Field calculator to caclulate the distance from the centroids of the hexagon to the closest point of the nearest feature on the layer park:
Another option to style each segment in a different style is to set symbol layer type to Geometry generator with this expression: segments_to_lines ($geometry).
Then you can use data driven override for styling (color, stroke width etc.) with the variable @geometry_part_num. See how and where to make the inputs:
Meanwhile (since QGIS 3.16), there is the new overlay_nearest function you can use for that with QGIS expressions. For each point, 1) get the nearest line with overlay_nearest, 2) get the closest point on this line to the point using closest_point.
The expression to be used with Geoemtry generator or Geomtry by expresssion (see here for details) look like:
As pointed out by @mikewatt, it seems like I cannot add a point geometry directly. The best I can do is use the GetPoint or GetPoint_2D methods and pass the Point geometry's coordinates to the LineString geometry, as shown below:
from osgeo import ogr
coords_p1 = [1214242.4174581182, 617041.9717021306]
coords_p2 = [1234593.1427447330, 629529.9167643716]
The point that is created has no SRID, i.e. 0, which is different than 4326.
That being said, st_distance uses the unit of the CRS, so degrees in this case.
One solution is to use geography instead of geometry, as the unit is meters, and to use st_dwithin() instead of st_distance as it makes use of spatial index. Eventually, you will want to add an index on ...
Use the following expression either with Geometry generator (for visualization purpose only) or Geometry by expression (to creare actual geometries) (see here for the difference) to create a polygon with areas more than 5 km away from all points:
buffer ( bounds (collect($geometry)), 5000),
buffer (collect (buffer ($geometry, 5000)), 0)