Recently I had the opportunity to work with the geospatial data regarding which we developed functions for calculation of the shortest route using different algorithms and route validation on different ways of transportation by sea as well.
For that I had to go back and bring to mind the geometry’s main concepts.
Geometry basics can be used for everyday tasks such as a home renovation project. Learning and understanding high school geometry basics
will come in handy more than you can think of in the future.
Geometry is used in construction, related to the beautiful design and construction of buildings, engineering, design, medicine, the study of outer space and robotics. I mention some illustrations of it in everyday life below.
Designers create a two dimensional pattern possessing only height and width that will be cut out, stitched and fitted onto a three dimensional body that has height, width and depth.

Formula One designs are particularly demanding since every angle and element must be exactly right in order to reach the winner’s circle.

If you take a good look around you you’ll find polygons everywhere. Becoming proficient in geometry takes practice. The basic geometry concepts build upon one another. As soon as you’re comfortable using basic geometry worksheets for one concept, you will often find yourself using what you already know in the next geometry lesson. In geometry, you are solving puzzles. Accept the challenge and before you know it, you’ll be having fun and acing the course.
To work more on manipulation and analysis of that data we can choose Python to develop this feature, in part due to the excellent Python libraries for geospatial programming: Shapely and Fiona. They are free and stable. These libraries are essentially wrappers for GEOS and OGR, respectively, which provide clean, Pythonic interfaces for performing the processing, while still keeping the performance capabilities of the underlying libraries.
Shapely does manipulating and data analyzing. It’d based on GEOS, the standard library for doing that kind of thing, that is very fast. With Shapely, you can do things likebuffers, unions, intersections, centroids, convex hulls, and a lot more. It does it all quite efficiently.
Fiona reads and writes data formats. For this it uses OGR, the most popular open-source conversion system.
Fiona is used for reading and writing vector files (here we’re using Shapefiles), while Shapely is used for doing the manipulation and analysis of the geometric objects. So let Shapely worry about the tricky spatial calculations and let Fiona worry about the tons of file formats. This way they work together efficiently.
Why not use GEOS or OGR directly?
GEOS, for one thing, doesn’t provide bindings to Python, so you’d need to use C++. You don’t want to write C++ for data-munging scripts. OGR does provide Python bindings, but they’re extremely ‘un-Pythonic’ — they don’t behave like other things in the language, and they’re very error-prone.
So, in a typical script, you would use Fiona for input and output, and Shapely for geodata manipulation. Got it? Let’s go.
To make this a bit more concrete, here are some quick recipes on how to do some basic things with Shapely based on what I have recently done in the past that you may find useful.
How to install them?
Windows
Follow the steps below to install Shapely/Fiona and geopandas on windows
Step 1: Download the Shapely/Fiona wheel from this website. Please pick the .whl package that correlates with your python interpreter as well system build (i.e. Shapely‑1.6.4.post2‑cp27‑cp27m‑win_amd64.whl, cp27 stands for python 2.7 and win_amd64 for OS 64 bit)
Step 2: Install them by using pip install path/to/file.whl
After you installed them successfully, you can create polygons simply from the shapely library:
from shapely.geometry import Polygon
poly =Polygon(((0, 0), (0, 1), (1, 1), (1, 0)
and after that you are able to check if a point is inside it.
Here are two ways, you can check if a point is in a polygon or if the polygon contains that point:point.within(polygon)polygon.contains(point)
Also you can take a look at this example, which demostrates the usage of Shapely and Fiona to locate high-risk traffic areas.
