New answers tagged

5

The question is about Shapely and Fiona in pure Python without QGIS ("using command line and/or shapely/fiona"). A solution is from shapely import shape, mapping import fiona # schema of the new shapefile schema = {'geometry': 'Polygon','properties': {'area': 'float:13.3','id_populat': 'int','id_crime': 'int'}} # creation of the new shapefile with the ...


3

You can do that in QGIS, without 'shapely' and 'fiona', by using PyQGIS. For a similar arrangement of shapefiles (see next image) from the answer in your link: How to calculate the size of a particular area below a buffer in QGIS This code: mapcanvas = iface.mapCanvas() layers = mapcanvas.layers() feats0 = [feat for feat in layers[0].getFeatures()] ...


3

I want to throw in my pyQGIS solution, nothing else. from PyQt4.QtCore import QVariant from qgis.analysis import QgsGeometryAnalyzer # get layers lines = QgsMapLayerRegistry.instance().mapLayersByName('lines')[0] clipper = QgsMapLayerRegistry.instance().mapLayersByName('clipper')[0] # prepare result layer clipped = ...


2

I guess its because you have a typo in your schema properties : 'intLanes': ':str' should be changed to 'intLanes': 'str' (the colon before str).


1

Thanks in a big way to @BradHands for pointing out that my suspicions that it was Shapely were incorrect. I noticed that the geom from Shapely was a POLYGON and in my SQLAlchemy model it was defined as MULTIPOLYGON. class States(Base): __tablename__ = 'states' state_id = Column(Integer, primary_key=True) abbreviation = Column(String) name ...


3

I don't think it is shapely. Using the data from your pastebin, and a simple test: >>> import shapely >>> from shapely.wkt import loads >>> state = loads('POLYGON ((-80.7856622716253 28.78519435427305, -80.76241527160364 28.73633435422754, -80.83210427166854 28.78618635427397, -80.85070527168587 28.78570035427352, ...


2

This would be easy in arcpy if there was a tool to split a line at a point but I cannot find one. If you run Integrate with the polygons and lines as inputs, it will add a vertex to each where they intersect. (Careful, as Integrate modifies inputs instead of producing new outputs.) Once you are sure there are coincident vertices, you can iterate over ...


2

There are three issues to contend with in this case: Holes Lines between polygons End lines Holes Since any line within a hole will be maintained, remove holes from polygons. In the script below I do so by use of cursors and geometries. Lines between polygons Lines that touch two polygons need to be removed. In the script below I do so by ...



Top 50 recent answers are included