Hot answers tagged

8

Given a polygon pol, like this: then: > library(sf) > sdist = -0.055168 > ppol = splitnarrow(pol, sdist, 1e-3) > plot(ppol, col=1:2) produces this: Here's the source code for splitnarrow. There's a zillion places where this can go wrong, and first you have to determine sdist and eps for your polygons. splitnarrow <- function(pol, sdist, ...


5

How to create polygons from MINx, MAXx, MINy and MAXy values Import the dataset as a delimited text layer without geometry (as an attribute-only table). Write an expression that combines the MINx, MAXx, MINy and MAXy fields into a polygon. One method is using the make_... geometry functions. First use the make_point() function to combine the corner ...


5

This would take you rather far afield, but one way to define the most narrow waist of a shape is to identify the event at which the straight skeleton partitions the shrinking shape into two pieces.                     Image from here (and probably copied from elsewhere). You can view the polygon ...


5

As per the comment, you need to choose the format you want to convert to by choosing the Save to file option in the 'Converted section, and then picking the format you want to convert to. You need to end up with a GDAL command that begins with ogr2ogr -f "LIBKML" You have to do this because the default option for this tool as per the documentation is ...


4

I am not sure how did you rotate the polygon grid, but it seems you have used Rotate tool from Processing toolbox. If so, you need to specify the Rotation anchor [x,y], which enables you to select the rotation position directly from the map canvas, as you can see below: Before rotation: Using Rotate tool: The Rotation anchor [x,y] was selected at the ...


4

How to split a vector layer and convert it to KML format The split vector layer tool creates geopackage files by default. If this is a process you do frequently, it may be worthwhile to follow the steps here to change the output setting for this tool. Otherwise, it takes two steps to split your layer and convert it to KML. Split the layer using the split ...


3

If you create a clipping layer with only the circular feature to use, your code can be simplified in this way (I use my own paths): from osgeo import gdal, ogr OutTile = gdal.Warp("/home/zeito/pyqgis_data/cut.tif", "/home/zeito/pyqgis_data/utah_demUTM12.tif", cutlineDSName='/home/zeito/pyqgis_data/boxes.shp', ...


3

You can create separate polygons in KML format directly when using the Convert format tool without using other tools as follows and using an example: This is a grid shapefile with 20 polygons Use Convert format tool from Processing toolbox -> GDAL -> Vector Conversion -> Convert format Select Input Polygon shapefile (20 polygons above in this ...


3

I use this code to ~randomly place a grid of sample plots for forest inventory: import numpy as np from itertools import product polylayer = iface.activeLayer() #Highlight polygon layer in layer tree npoints = 8 #Change pointlayer = QgsVectorLayer('Point?crs=epsg:3006', 'point' , 'memory') #Change epsg prov = pointlayer.dataProvider() for poly in ...


3

I implemented Cyril's comment. This is the input test polygon: Polygon to Lines Split lines by maximum length using $length / 7 in the expression builder. (8 vertices) Extract specific vertices (0 stands for start point) Voronoi Polygons with 100% buffer to make sure that parts of the polygon do not lie outside the generated Voronoi (in theory they may ...


3

There are a bunch of tools that can help with this. Check out this article for more details: http://desktop.arcgis.com/en/arcmap/10.4/manage-data/editing-fundamentals/removing-slivers-or-gaps-between-polygons.htm More specifically the Align to Shape tool will hopefully solve your problem: http://desktop.arcgis.com/en/arcmap/10.4/manage-data/editing-existing-...


2

If I correctly understood the translation of your question, try running this script: If these are horizontal lines, then: create table line_to_poly as WITH closed_contours AS ( SELECT ((ST_Dump(ST_Polygonize(geom))).geom) FROM sourse_table) SELECT (ST_Dump(ST_Union(geom))).geom FROM closed_contours If polygons, then: create table un_poly as ...


2

To keep only the points that are in the green layer, find the Select by location tool in the Processing Toolbox. Use the Select by location tool with the following settings: Select features from point layer Where the features (geometry predicate) intersect By comparing to the features from polygon layer Now you have selected all the points that fall inside ...


2

Here is a solution that I think will work for you: Go to Plugins and install the mmqgis-plugin Use the plugins' combine function to merge your layers. Save/export the combined layer as KML.


2

I would go with... SELECT Box2D(geom) as bounds, ST_YMax(bounds) as ymax, ST_YMin(bounds) as ymin, ST_XMax(bounds) as xmax, ST_XMin(bounds) as xmin FROM nation_shapes WHERE (condition) ...as PostgreSQL's SQL engine and query planner is smart enough to figure things out and not duplicate work. If you want to not return the bbox from ...


2

I am assuming that what you see is the result of invalid geometries inserted by whatever software created your "polygon mesh". f you try to compute area, then I expect that you will see negative results for some of the polygons. Using the Repair Geometry tool will fix it.


2

To convert a simple polygon P (that defines an area) to a line L use: L = st_cast(P,"LINESTRING") eg using pl from example(st_polygon): > st_polygon(pl) POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0)) > st_cast(st_polygon(pl),"LINESTRING") LINESTRING (0 0, 1 0, 1 1, 0 1, 0 0)


2

Let's reproduce your sample data: charters=data.frame( school.name=c("oceanside","discovery"), school.id=c("008229","228881"), district.id=c("3400011","340020"), lat=c(39.3635, 40.7343), lon=c(-74.4350,-74.1745)) then make it a spatial points data frame: coordinates(charters)=~lon+lat assume the lat-long in charters is the same sort of lat-...


1

I guess it is the same problem as here: Rasterize (Vector to raster) ERROR 6 In the options dialogue in the rasterize-tool, set burn-in value to 1 (to get black value for the extent of your polygon) and select a resolution (like units for output-raster in pixels and horizontal and vertical resolution set to 100 - or more if you wand a smoother image, or ...


1

@Vince gave an educational comment, @Cyril named it directly, and I like to avoid further confusion; the simple answer is: clip those grometries! All queries present in this post do one thing, one way or another, that is selecting every row whose geometries minimum bounding rectangle, the bbox, intersects the created envelope, another bbox. And that's ...


1

As @Marcelo Villa said, you are trying to pass a GeoDataFrame into an ee.Geometry constructor which fails because it is expecting geojson like information. You will need to extract the information needed from the GeoDataFrame to create the feature object. Here is an example: shapefile = gpd.read_file("polygon.shp") features = [] for i in range(shapefile....


1

Good day, I’m moving from theory to practice, the initial data is a layer (table) with the name adm_polygons, run the script: WITH ta AS ( WITH at AS (SELECT id, (ST_ExteriorRing(((ST_Dump(geom)).geom))) as geom FROM adm_polygons), intervals as (SELECT generate_series (0, 8) as steps) SELECT steps AS stp, ST_LineInterpolatePoint(geom, steps/(...


1

In situations like this where the intent is to select existing geometry rather than construct new geometry it's preferable to avoid using overlay operations (like ST_Union) since they are less performant and can alter data slightly. Instead, it's better to use spatial relationships. This is a classic case of "finding things which aren't related to other ...


1

You could use ST_Union to generate one big multipolygon and then ST_Dump to separate its component polygons into separate records. If you then needed to get attributes from the original data you could join based on geometry.


1

In the Rasterize tool, notice the option to set a nodata value: Assign a specified nodata value to output bands [optional] You have 0.000000 set as the optional nodata value, so all polygons with 0 in their burnin field are converted to nodata values in the raster. Clear the nodata value by clicking the X button in the nodata box:


1

I noticed later that, even being only one feature, there were tiny islands around the boundary, and maybe the issue was in those. But i wasn't able to delete all of them, because i was in a hurry. So, to solve my issue, i used Simplify, with "Distance (Douglas-Peucker)" method, using a 1km tolerance. Any type of polygon based directly on the original (...


1

Your polygon seems to be two copies of the same ring, exactly overlapping. Look at the first five points and then the first five after the half-way mark: > polygons[1:5,] x y n 288842 4.232 20.240 5 288851 4.232 20.248 5 288861 4.232 20.256 5 288871 4.224 20.264 5 288881 4.224 20.272 5 > polygons[(nrow(polygons)/2)+(1:5),] x ...


1

If you just want to hide points for visual purposes and don't want to create a new shapefile: Follow the instructions in ahmadhanb's answer to select all points which intersect your polygon. Open field calculator for of your point layer. Ensure the 'Only update xx selected features' box is ticked. Create a new field named "Filter". Field type can be integer....


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