New answers tagged

1

Use Menu Raster / Converstion / Rasterize, select the polygon and the value you want to add, 200 in your case. Select Pixel size (Width/Horizontal resolution and Height/Vertical resolution) from the raster layer. Be sure that Assign a specified nodata value to output bands is empty (not set). See screenshot: Output is a black/white raster as seen on the ...


2

There are four simple steps that you can perform at once using the expression from below with Geometry generator or Geomtry by expression (see how here). In brackets you see on which line of the expression this task is performed: Extend the line (lines 4 to 8) so that it continues well over the boundary of the polygon. Change the length the line is extended ...


3

If you'd want to zoom in on the polygon, simply use view.fit . See example on OL website https://openlayers.org/en/latest/examples/center.html To calculate the actual centroid of the polygon you could use a library such as turf js


1

I did not have success with the Line-Polygon tool. I converted my polygon to lines and then used the SAGA->Vector line tools->Split lines with lines. This worked for me.


5

You can use the following structure. For other rectangles, add the highlighted lines (between ###) to a for loop. layer = QgsVectorLayer("Polygon?crs=EPSG:2193", "Polygons", "memory") QgsProject.instance().addMapLayer(layer) #### Coordinates coming from CSV ### xMin = 1804512.8556 yMin = 5453390.58088 xMax = 1813512.8556 yMax = ...


3

Try the code snippet below. This will create a temporary layer, add a polygon feature with geometry created from a QgsRectangle and add the memory layer to your project. You also need to know what CRS your csv coordinates are in and tell QGIS about it. I have commented the code to show you where to specify the CRS. project = QgsProject().instance() rect = ...


4

There is an equivalent tool, namely Rectangles, Ovals, Diamonds, in the QGIS's Toolbox Ctrl+Alt+T > Vector geometry.


5

Re-project your polygon to a pacific-centered CRS (the same you use as project CRS: EPSG:3832; or the same I used EPSG:8859) and set the project CRS to the same projection. Than you can split the polygon. With other CRS ending at the International Date Line (like 4326), I encountered the same problem as you, as well as when I had different CRS for layer and ...


1

It should be as simple as, from the Processing Toolbox: Open the Random Points Inside Polygons tool Select your polygon layer as the input layer Use the Points count sampling strategy Click on the Data defined override button to the right of the count/density field Select your value field in the Field submenu The data override uses the field value as a ...


0

I would implement the solution that is describe here Geometry based automatic fill of fields in attribute table The solution is essentially a trigger that will update the field automatically when ever a transaction occurs. This way, the data will not only populate the field upon data creation, but also if geometry changes. I would also move off of using a ...


3

You can use a simple query in DB Manager, like: SELECT bldg.* , count(quakes.id) FROM "New Scratch Layer" AS bldg, Buffered AS quakes WHERE st_intersects(quakes.geometry,bldg.geometry) GROUP BY bldg.ID Then Load it as a layer in the DB Manager (at the bottom) and style it to show by number of quakes. The attribute table will have the counts. INPUT ...


0

This can also be done by adding a point symbol as a backgound to a label on the polygon layer and then making the label text invisible.


5

Another approach using the "Extract by location" with 'intersect' as geometric predicate, see image below. To get more familiar with geometric predicates, please check this answer.


0

You may want to use one of these functions in Vector -> Geoprocessing Tool


0

I ended up using the Intersection feature in Processing -> Toolbox -> Vector overlay to identify the area of overlap of the two shapefiles. Then, using the resulting shapefile, I went to the Attributes table -> Open Field Calculator and created a new field using $area. With this I got the area of each polygon which I ended up exporting as a csv ...


0

Writing Geometries works if you format the text (i.e. coordinates) as shown below. I recommend scripting this to speed the process up by iterating over each .txt file in the folder and extracting the coordinates, then creating a polygon of each area. scratch = arcpy.management.CreateFeatureclass(arcpy.env.scratchGDB, "Counties", "...


3

This may not be the best and smartest solution, but a working one. Let's assume there is a point layer 'points', see image below. Idea 1. Using the "Minimum bounding geometry" geoalgorithm. Proceed with Plugins > Python Console > Show Editor and paste the script below import processing # providing the point layer's name layer_name = "...


1

Create a polygon-grid (squares) over you buffer polygons in the same size that you want your pixels to be (in my case: 1x1 meter). The extent of the grid should be the same as the buffer layer. Than calculate how many buffers each grid-cell covers. You can do this calculating a new attribute with field calculator and an expression like this: array_length ( ...


0

It is likely that there are better ways to do this but the scale of the problem didn't make this (probably inefficient) approach too bad. I ended up doing a double loop over points and polygons. For each point, I computed the distance to all polygons of a different flood zone designation (one at a time). After going over all points and polygons, I computed ...


1

Unfortunately, your question is still a little confusing. You use the word grid, which leads me to believe that you are actually working with raster data. I may be wrong, but will answer with the raster assumption: With the Spatial Analyst extension, you have a couple of choices to summarize overlapping raster grids: The Plus tool will sum, cell-by-cell, ...


5

You could try something like: make_ellipse(centroid($geometry),bounds_width($geometry)/2,bounds_height($geometry)/2,main_angle($geometry),45) 45 is the number of segments, change that to whatever smoothness you wish. Or alternatively if the main_angle() does not match your needs, try something like: make_ellipse(centroid($geometry),bounds_width($geometry)/2,...


13

Create Oriented minimum bounding box From these, create elipses with values from the attribute table calculated in the first step: make_ellipse(centroid ($geometry), "height"/2, "width"/2 ,"angle") Screenshot: here with segements=200 for a smooth ellipse (blue):


4

Meanwhile (since QGIS 3.16 with the new overlay_crosses function) you can use QGIS expressions to automatically calculate what you want. The expression to use on the lines layer and referring to the polygon layer (replace polygon with the name of your polygon layer) looks like this - see below for an explanation. You can use this expression with field ...


2

What you seem to mean is how often does each line cross the boundary (outline) of each polygon. When a line crosses a polygon, the number of intersection points is infinite as the intersection has the form of a line and this consists of an infinite number of points. To count the number of crossing points with the boundary, first convert your polygons to ...


2

I would explore the various clustering plugins available for QGIS. "Attribute based clustering" Plugin may be what you need, but there are several more available.


5

You can dissolve you layer based on category: Menu Vector / Geoprocessing Tools / Dissolve, select the attribute that contains the category in the optional Dissolve field(s) option. On the created layer, run Menu Vector / Geometry Tools / Multipart to singleparts. You get a new layer with one feature for each cluster. On this layer, create an attribute for ...


0

Create a new layer and add a new polygon feature by clicking the Add Polygon Feature icon, see the documentation. Than manually draw the polygon you like.


6

You can achieve this using ogr2ogr with # SHP from Natural Earth Data ogr2ogr out.shp ne_110m_admin_0_countries.shp -dialect SQLite -sql "SELECT * FROM ne_110m_admin_0_countries WHERE ST_intersects(ST_Buffer(ST_GeomFromText('POINT (1 43)', 4326), 10), ne_110m_admin_0_countries.geometry);" To sort out execution with index, you may want to add after ...


1

It seems that the slowest part of the code is the call to Moran. I am using raster::extent in lue of sf::st_bbox which seems to make a difference. I also moved the for loop into an lapply. Let's add libraries and create some example data. I would recommend reading the data into R as a stack, and index out of the stack, rather than repeatedly reading a raster ...


0

toolEventInfo.selected This does not seem to be documented anywhere (as of 4.18, even if using the 4x typings), but through debugging, I was able to find pathIndex (previously segmentIndex) and pointIndex in the event fired from sketch.update sketch.on("update", (event) => { const toolEventInfo = event.toolEventInfo; if (toolEventInfo &...


3

The Vector - Geoprocessing Tools - Buffer tool in QGIS is applied to all features in a layer. Buffered features can also be dissolved, so that overlapping buffers are not created, if required. This reduces the number of features in the output. The number of items in the attribute table will reflect this.


1

When converting to .DXF, QGIS polygon features are converted into CAD hatch features, and QGIS line features are converted into CAD polyline features. Points are a little more complicated to explain, as it can depend on the symbology used to display the points in QGIS. It is important to pay attention to the [Symbology mode] setting in the QGIS [DXF Export] ...


3

There are two sets of classes for spatial data in R, and you are mixing them. They do not mix. The sp package provides the classes that start Spatial...., such as your SpatialPointsDataFrame. Then the sf package provides different classes for the same sort of data, and these are usually called "sf classes" or "spatial data frames". You ...


0

Get area using dplyr::mutate and sf::st_area library(sf); library(dplyr) p <- st_read("polygon.shp") p %>% mutate(crown_area_m2 = as.integer(st_area(p))) or simply p %>% mutate(crown_area_m2 = st_area(p))


1

This was a solution for my problem: public drawPolygon(points: LonLat[]): Feature { let coordinates : Coordinate[] = []; points.forEach(function (point) { coordinates.push(fromLonLat([point.lon, point.lat])) }); let convexHullCoordinates = this.convexHull(coordinates); let feature = new Feature(new Polygon([convexHullCoordinates])); return feature;...


0

The issue got resolved. Since the database has layers from different sources, the CRS of one particular layer was not appropriate for web display. After reprojecting, the application is working perfectly now.


1

I wasn't able to download buildings data from OSM with a polygon (shapefile) as the bounding box however I was able to using distance from a point with the following code: import osmnx as ox import ast point = 'point coordinates' dist = 'distance in m' buildings = ox.geometries.geometries_from_point(point, {'building': True}, dist=dist) And convert to a ...


0

Use Vector - Geometry Tools - Lines to Polygon. This will close all polylines (join the last point to the first). Then export to KML


2

This question has good answers already, but I thought I'd provide a dynamic solution for anyone who has this problem specifically with polygons that are only 4-sided (for example, rectangles showing the extents of lots of smaller maps over a larger map). This solution involves writing several python functions in the Function Editor. I am sure there are ways ...


Top 50 recent answers are included