New answers tagged

1

You mix two thinks, Shapely and the GeoJSON format. By definition, Shapely process geometric objects and does not deal with attributes from shapely.geometry import GeometryCollection, mapping s = GeometryCollection() # GeoJSON format geo = mapping(s) print geo {'type': 'GeometryCollection', 'geometries': []} Now if you want to add attributes, you can ...


1

There's a problem between ctypes (the Python ffi module) and GEOS shared libs on OS X such that the state of the GEOS lib is corrupted when you load it again via import shapely. It's not a problem on Linux, as far as I can tell. The Fiona wheels for macosx and Python 2.7, 3.4, and 3.5 on PyPI have statically linked GEOS libraries and won't interfere with ...


4

The native shapely function is unary_union (Planar graph) The circles 1) Using the script of How to find the intersection areas of overlapping buffer zones in single shapefile? rings = [LineString(pol.exterior.coords) for pol in circles] union = unary_union(rings) result = [geom for geom in polygonize(union)] Result: you have all the intersections ...


1

The Shapely distributions I am making for OS X (https://pypi.python.org/pypi/Shapely#downloads) have GEOS included and you won't have to think about library paths at all. If you're using Python 2.7, 3.4, or 3.5 and OS X 10.6+, pip install shapely is the best way to get it.


2

You have to point your system to where the GEOS Framework is located. See this post: DYLD_LIBRARY_PATH="/Library/Frameworks/GEOS.framework/Versions/3/unix/lib" export DYLD_LIBRARY_PATH If it works, add it to your $PATH!


0

You need the full shapefile, so better look into https://trac.openstreetmap.org/browser/subversion/applications/editors/merkaartor-branches/merkaartor-0.14-fixes/share/world_shp?rev=17052 and get all three files. Projection information is missing, so you have to assign WGS84 EPSG:4326 to it. Alternatively, take a full copy from Natural Earth. The Albers ...


1

You can build a custom mercator projection centered approximately on the center of the swath. For example, use for swath 25: +proj=merc +lon_0=-140 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs In this projection, the swath is not broken by the dateline. You can create the polygon from the line. Then create a cut polygon ...


1

I would rewrite the swathe line generation process to start and finish in the same continuous longintudinal space. ie if a line started at 170° and finished at -170° I would rewrite the process to finish at 190° instead without wrapping at -180,180 Then you can make unbroken polygons between your lines. Then use a clip process to split the polygons at the ...


1

Shapely and GEOS cannot reduce precision (floating-point precision problem) but you can use other functions as numpy.round() or round(),with the GeoJSON format. For polygons from shapely.geometry import shape, mapping import numpy as np # one polygon print poly.wkt POLYGON ((101.2200527190607 -114.6493019170767, 146.6225142079163 -114.4488495484725, ...


0

I don't see any way to reduce precision with Shapely even though GEOS, the base geometry engine, has precision reducer classes. You might try ogr2ogr. The geoJson driver has a "Coordinate Precision" option. You can export to geojson then create a shapefile from geojson. Just an idea.


2

the geoalchemy2 wkb_element is just an object that contains the srid, accessible as wkb_element.srid. The SRID information should be updated in the column of the table by doing SELECT UpdateGeometrySRID('points','geom',26918); after you imported the data from the file. If you do it before you import the data, you would get an error Geometry SRID (0) ...


1

You can use the properties of union (and unary_union) witch split all the lines at intersections (Planar graph) # LinearRing of the polygons ringgreen = LineString(list(polygreen.exterior.coords)) ringblue = LineString(list(polyblue.exterior.coords)) # Union of the rings union = ringgreen.union(ringblue) # now polygonize the result from shapely.ops ...


0

Although not a complete answer, I think I have an algorithm that could work. For each point in poly1, if the Point is closer than epsilon to a LineString in poly2 then move the Point onto the LineString. For each pair of Point objects (one from poly1 and one from poly2) if the two are closer than epsilon then move both to the central point between them. ...


0

I still think that I not understand what you are trying to do with your script (and his complexity) The original layer I use the simple script presented in How to find the intersection areas of overlapping buffer zones in single shapefile? (new) (without rtree, many for loops and intersections) to create the resulting shapefile. By definition, all ...



Top 50 recent answers are included