Giter Site home page Giter Site logo

alexfe96 / shapely Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shapely/shapely

0.0 0.0 0.0 3.33 MB

Manipulation and analysis of geometric objects

Home Page: https://shapely.readthedocs.io/en/latest/

License: BSD 3-Clause "New" or "Revised" License

Shell 0.73% Python 99.12% Batchfile 0.15%

shapely's Introduction

Shapely

github-actions appveyor coveralls

Manipulation and analysis of geometric objects in the Cartesian plane.

image

Shapely is a BSD-licensed Python package for manipulation and analysis of planar geometric objects. It is based on the widely deployed GEOS (the engine of PostGIS) and JTS (from which GEOS is ported) libraries. Shapely is not concerned with data formats or coordinate systems, but can be readily integrated with packages that are. For more details, see:

Usage

Here is the canonical example of building an approximately circular patch by buffering a point.

>>> from shapely.geometry import Point
>>> patch = Point(0.0, 0.0).buffer(10.0)
>>> patch
<shapely.geometry.polygon.Polygon object at 0x...>
>>> patch.area
313.65484905459385

See the manual for more examples and guidance.

Requirements

Shapely 1.8 requires

  • Python >=3.6
  • GEOS >=3.3

Installing Shapely

Shapely may be installed from a source distribution or one of several kinds of built distribution.

Built distributions

Built distributions are the only option for users who do not have or do not know how to use their platform's compiler and Python SDK, and a good option for users who would rather not bother.

Linux, OS X, and Windows users can get Shapely wheels with GEOS included from the Python Package Index with a recent version of pip (8+):

$ pip install shapely

Shapely is available via system package management tools like apt, yum, and Homebrew, and is also provided by popular Python distributions like Canopy and Anaconda. If you use the Conda package manager to install Shapely, be sure to use the conda-forge channel.

Windows users have another good installation options: the wheels published at https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely. These can be installed using pip by specifying the entire URL.

Source distributions

If you want to build Shapely from source for compatibility with other modules that depend on GEOS (such as cartopy or osgeo.ogr) or want to use a different version of GEOS than the one included in the project wheels you should first install the GEOS library, Cython, and Numpy on your system (using apt, yum, brew, or other means) and then direct pip to ignore the binary wheels.

$ pip install shapely --no-binary shapely

If you've installed GEOS to a standard location, the geos-config program will be used to get compiler and linker options. If geos-config is not on your executable, it can be specified with a GEOS_CONFIG environment variable, e.g.:

$ GEOS_CONFIG=/path/to/geos-config pip install shapely

Integration

Shapely does not read or write data files, but it can serialize and deserialize using several well known formats and protocols. The shapely.wkb and shapely.wkt modules provide dumpers and loaders inspired by Python's pickle module.

>>> from shapely.wkt import dumps, loads
>>> dumps(loads('POINT (0 0)'))
'POINT (0.0000000000000000 0.0000000000000000)'

Shapely can also integrate with other Python GIS packages using GeoJSON-like dicts.

>>> import json
>>> from shapely.geometry import mapping, shape
>>> s = shape(json.loads('{"type": "Point", "coordinates": [0.0, 0.0]}'))
>>> s
<shapely.geometry.point.Point object at 0x...>
>>> print(json.dumps(mapping(s)))
{"type": "Point", "coordinates": [0.0, 0.0]}

Development and Testing

Dependencies for developing Shapely are listed in requirements-dev.txt. Cython and Numpy are not required for production installations, only for development. Use of a virtual environment is strongly recommended.

$ virtualenv .
$ source bin/activate
(env)$ pip install -r requirements-dev.txt
(env)$ pip install -e .

The project uses pytest to run Shapely's suite of unittests and doctests.

(env)$ python -m pytest

Support

Questions about using Shapely may be asked on the GIS StackExchange using the "shapely" tag.

Bugs may be reported at https://github.com/Toblerity/Shapely/issues.

shapely's People

Contributors

ahojnnes avatar allanadair avatar aronbierbaum avatar astrojuanlu avatar bartbroere avatar bradh avatar chadwhawkins avatar cprima avatar dethi avatar drnextgis avatar ewsterrenburg avatar georgeouzou avatar geowurster avatar hobu avatar hugovk avatar jeremiah-england avatar jgaboardi avatar jorisvandenbossche avatar jwass avatar kannes avatar kveretennicov avatar mindw avatar mwtoews avatar olt avatar pelson avatar ppaci avatar sgillies avatar snorfalorpagus avatar thedavecollins avatar tomplex avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.