Tag Info

New answers tagged

4

Some remarks because you mix many things ( if you want yo use your script outside the console of QGIS, install the Python module GDAL (osgeo) in your Python installation: it is installed in the Python version of QGIS if you are on Windows). 1) There are no Shapely geometries in your script, only PyQGIS geometries QgsPoint(x_min, y_min), ... ogr geometries ...


3

If you use Shapely, transform your polygon into a LinearRing or a LineString from shapely.geometry import shape import fiona Multilines = MultiLineString([shape(line['geometry']) for line in fiona.open("lines.shp")]) Poly = shape(fiona.open("one_poly.shp").next()['geometry']) Multilines.intersection(Poly) <shapely.geometry.multilinestring.MultiLineString ...


0

It looks like your coordinates are longitude and latitude, yes? Use Shapely's shapely.ops.transform function to transform the polygon to projected equal area coordinates and then take the area. python geom_aea = transform( partial( pyproj.transform, pyproj.Proj(init='EPSG:4326'), pyproj.Proj( proj='aea', lat1=geom.bounds[1], ...


3

The intersection of a Polygon and a LineString is a LineString and the intersection of two LineStrings is a Point (or MultiPoint), so you need to transform your Polygon into a LineString -> Shapely: LinearRings from shapely.geometry import shape import fiona # polygon layer poly = fiona.open("polygons.shp") # line layer line = fiona.open("lines.shp") # ...



Top 50 recent answers are included