Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
(1) abstract geometry; (2) storing geographic data in projected coordinates; (3) a generic ESRI term for vector features; a class for "geometry" objects.
1
vote
Calculating the sum of perimeters of all polygon features in QGIS
Another option is to use the Statistical Summary tool.
Type $perimiter in the input:
0
votes
Read GeoJSON object in a CSV file column and transform it to geometry
"] = df.apply(lambda x: shape(ast.literal_eval(x.col1)), axis=1)
df = gpd.GeoDataFrame(data=df, geometry=df["geometry"], crs=4326)
df.geometry
Out[100]:
0 LINESTRING (5.80703 43.19285, 5.80731 43.19276 … )
Name: geometry, dtype: geometry …
1
vote
More efficient way to use Symmetrical Difference tool for layer with many features
Having large complex geometries will slow down processing.
Try:
Multipart To Singleparts
Subdivide
3. And Create Spatial Index
On both input layers
5
votes
Drawing perfect square in QGIS
Execute the query and "Load as new Layer"
select row_number() over() as id, st_envelope(st_buffer(geometry, 200.0, 16)) as geometry
from "My point layer"
Place a point in the center of where you want …
5
votes
Accepted
How to identify holes of missing geometry enclosed within a polygon in QGIS?
Try this workflow:
My starting layer, some holes along the borders and inside:
Dissolve
Delete holes
Difference the Delete holes output with the start layer to create polygons where there are h …
2
votes
Accepted
Intersection between polygons. Is gpd.sjoin adjustable?
You can:
Create a column where you save the larger polygon geometries,
then spatial join the larger polygons to the smaller
Calculate the overlap area (using the saved geometry and the spatial join geometry … True
print(sj.loc[sj["id_left"]==1][["id_left", "id_right"]])
# id_left id_right
# 0 1 9.0
# 0 1 10.0
#Calculate overlap areas
sj["overlap_area"] = sj.apply(lambda x: x["geometry …
4
votes
Accepted
How to extract the overlay line geometry length using geopandas?
Intersect, calculate line length, sum and merge it back to the polygon df:
import geopandas as gpd
hexgrid = gpd.read_file(r"C:\GIS\GIStest\hexgrid.shp")
hexgrid["gridid"] = range(hexgrid.shape[0]) # …
5
votes
Fixing holes in the buffered polygon using PyQGIS
Delete holes:
Takes a polygon layer and removes holes in polygons
Use buffer output as input:
layer = iface.activeLayer()
buffered = processing.run("native:buffer",
{'INPUT':layer,'DISTANCE':1 …
6
votes
Accepted
Is there a common method for measuring "curviness" of a line?
One measure is Sinuosity which is the line length divided by the shortest distance from the line start and end points:
select id,
st_length(geom)/st_distance(st_startpoint(geom), st_endpoint(g …
4
votes
Accepted
How do you flip/invert/reverse the order of the coordinates of shapely geometries?
This is now very easy with the .reverse method:
import shapely
line = shapely.wkt.loads("LINESTRING (0 0, 1 1, 3 1, -3 3)")
multiline = shapely.wkt.loads("MULTILINESTRING ((120 105, 140 98),(160 103, …
5
votes
Accepted
From Geodataframe to PostGIS
You shouldnt need dtype={'geom': Geometry(geometry_type='GEOMETRY', srid= 4326)}. … use .to_postgis:
import geopandas as gpd
from sqlalchemy import create_engine
gdf = gpd.read_file(r"/home/bera/Desktop/GIStest/distances_houses/house.geojson")
# gdf.dtypes
# houseid object
# geometry …
7
votes
Finding overlapping polygons within the same layer in QGIS
Modify layer name (row 3 and 4) and the id column name (row 6) in the query below and execute:
select row_number() over() as newid,
st_intersection(a.geometry, b.geometry) as geometry
from "qwerty …
2
votes
Generate lines from given azimuth and points in GeoPandas
= gpd.points_from_xy(x=df["lon"], y=df["lat"], crs=4326)
df = gpd.GeoDataFrame(data=data, geometry=geometry, crs=4326)
df = df.to_crs(3829) #You need to have a projected coordinate system with meters … endy"])]), axis=1)
df = df.set_geometry("line").drop(columns="geometry").rename_geometry("geometry").set_crs(3829)
df.to_file(r"C:\GIS\data\testdata\lines.shp") …
1
vote
Snap points to polygon/lines in python shapely?
range(point.shape[0])
#For each point find the closest polygon(s)
# If there are more than one polygon within snapdistance, the points will be duplicated
poly["polygeom"] = poly.geometry #Save the geometry … NaN None
sj["geometry"] = sj.apply(lambda x: snap(x.geometry, x.nearestpoint, snapdist)
if x.nearestpoint is not None else x.geometry, axis=1) #Snap …
5
votes
Accepted
Unifying touching polygon within polygon geometry in PostGIS
I can recommend this way, it is very fast.
Each group of polygons is assigned the same id if they are 0 distance apart, and number at least 2, using ST_ClusterDBSCAN.
Single polygons will get NULL as …