How to write shapely geometries to shapefiles?
Here is a very simple example of using them together to “clean” shapefile features: From https://github.com/Toblerity/Fiona/blob/master/examples/with-shapely.py. You can also write Shapely geometries by using PyShp (since the original poster also asked about PyShp).
How do you save pyshp shapes in writer?
To save them you then simply append each resulting pyshp shape to the shapefile.Writer instance’s ._shapes list (for an example see the test script at the bottom of this post). Note however: the function will NOT handle any interior polygon holes if there are any, it simply ignores them.
How can I convert shapely geometry to GeoJSON?
One way would be to convert your shapely geometry to geojson (with the shapely.geometry.mapping method) and then use my modified fork of PyShp which provides a Writer method that accepts geojson geometry dictionaries when writing to a shapefile. If you would rather rely on the main PyShp version, I have also provided a conversion function below:
Where can I find the API for shapefile?
You may check out the related API usage on the sidebar. You may also want to check out all available functions/classes of the module shapefile , or try the search function .
How to import a polygon from shapely on Windows?
For the initial install under which I couldn’t import the geometry sub-module I installed shapely with the command: However after reading the documentation here more closely I saw that for Windows an executable installer needed to be used.
How to uninstall the first version of shapely?
So I uninstalled the first version of shapely with: Then I launched the installer via the wheel file like this: Note that you must download the wheel that matches the specs of the version of python that your applying the package to. I have 32-bit ( win32) python 2.7 ( p27) so the package above was the correct one.