Why wrap shapely? We wanted three different abilities. Protobuf support, a required spatial reference and spatial reference aware geometry operations.
We wanted to import, export and operate on protobuf geometries and envelopes. Our microservices communicate using protobufs, so it made sense for us to have a helper library that allowed us to work with the geometries on our client and quickly construct protobufs for messaging.
We never want a geometry separate from it's spatial reference details. We could have solved this by working exclusively with the geojson idea of always Wgs84, but we've found time and again that projected geometries exist and must be worked with. So instead of letting geometries float around without their coordinate system information we decided to tie it to the geometry, much like ESRI does with ArcObjects.
We wanted easy projections and operators that returned results according to their spatial reference tolerance (geodetic buffer, area, and topo relationships). Most of the old shapely operators behave the same as they did before (with exception of project and generalize), but now they use a remote geometry service that requires spatial reference information. We've kept the native shapely topo operators and changed their names to use the s_ prefix.
There are a few differences between how shapely behaves and how this wrapper functions.
projectis now mean to project a geometry from one spatial reference to anothersimplifyfixes a broken geometry. To remove vertices from a geometry uses_simplifyorgeneralizeareais no longer a property. it's a method and it defaults to geodetic (internally it usesgeodetic_area). the default result unit is meters squared. to force non-geodetic usegeodetic=Falsecarto_boundsproperty is used for the bounds order cartopy preferscarto_geomreturns a shapely geometry (as doesshapely_dump). Cartopy doesn't want wrapped shapely geometries, it wants the real thing.bufferdefaults to geodetic (like area). The distance you specify is in meters. You can override withgeodetic=Falsesrfield on geometry returns a SpatialReferenceData protobuf object- initializing geometry requires a spatial reference, sr, wkid or proj4 definition
This requires the gRPC geometry library and docker. You need to build the service as the docker hosted echoparklabs/geometry-service-java is out of date.
git clone https://github.com/geo-grpc/geometry-service-java.git
cd geometry-service-java
docker build -t echoparklabs/geometry-service-java .
docker run -p 8980:8980 -d echoparklabs/geometry-service-javainstall using pip (depends on shapely, epl.protobuf and grpc)
pip install epl.geometryinstall for development
pip install -r requirements.txt
pip install -r requirements-test.txtpip install -r requirements.txt
pip install -r requirements-demo.txt
jupyter notebookif you have virtualenv installed
python -m ipykernel install --user --name=geometry-client-pythonif cartopy crashes (issues 738 and 879):
pip uninstall cartopy
pip uninstall shapely
pip install shapely --no-binary shapely
pip install cartopy --no-binary cartopy
jupyter notebook