Hot answers tagged

3

Pyshp does not have a WKT method but it does support the geo_interface protocol at the shape level. That protocol returns each shape as geojson. You can then use the lightweight, pure-python pygeoif module to convert to WKT. The pygeoif module is available on the Python Package Index and Github: https://pypi.python.org/pypi/pygeoif/ https://github.com/...


3

So are you wanting to add to the existing features? If so, have a look at the Append tool. It will keep the original features and continue to add to them. Note that the features should have the same schema.


2

I am not sure I really understand what you are doing. How can a point cluster be a collection of linestrings? , but .. Remember you are using a spatial database, why not use the functionality in PostGIS? from a bunch of points you can collect them and use ST_Centroid on the collection. Or if it really is a collection of linestrings that you want to get ...


2

The Example from the spatialite cookbook https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/new-geom.html denotes: SELECT AddGeometryColumn('test_geom', 'the_geom', 4326, 'POINT', 'XY'); Strings are quoted here, so try to modify your comand to cur.execute("SELECT AddGeometryColumn('%s', '%s', %s, '%s', '%s')" %(table_name, geometry_column_name, ...


2

GDAL has no problem with GeoJSON http://geojson.org/geojson-spec.html. The following GeoJSON encodes one multilinestring: { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": {"type":"MultiLineString","coordinates":[[[11.20558631,46.48251782],[11.2058444,46.48280049]],[[11.20578705,46.48252192],[11.20596731,46.48275133]]],"crs":{"...


2

Try out with 'intersects' and 'intersection' methods. Next code produces only two points. mapcanvas = iface.mapCanvas() layers = mapcanvas.layers() feats_line = [ feat for feat in layers[0].getFeatures() ] feats_poly = [ feat for feat in layers[1].getFeatures() ] for feat_l in feats_line: for feat_p in feats_poly: if feat_p.geometry()....


1

You need to iterate through the segments of the line to find the one that touches/intersect the polygons (as in Get the vertices on a LineString either side of a Point) I show here the results with one line and one polygon as example # transform the line to a list of points linegeom = liengeom.asPolyline() # extract the segments seg_start, seg_end of ...


1

I am not sure if this is a more efficient way but you could also compare the area of the input polygon to the area of the convex hull of the same polygon. Idea: The area of the convex hull of a concave polygon is always bigger then the area of the concave polygon itself. Simple method: public static boolean isConvexPolygon(Polygon p){ // calculate ...



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