All Projects → afourmy → pyGISS

afourmy / pyGISS

Licence: MIT license
📡 A lightweight GIS Software in less than 100 lines of code

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to pyGISS

Pyearth
🌐 A lightweight 3D visualization of the earth in 150 lines of Qt/OpenGL
Stars: ✭ 78 (-31.58%)
Mutual labels:  pyqt5, geospatial, gis, shapefile
EarthSim
Tools for working with and visualizing environmental simulations.
Stars: ✭ 61 (-46.49%)
Mutual labels:  geospatial, gis, geographic
Shapefile.jl
Parsing .shp files in Julia
Stars: ✭ 40 (-64.91%)
Mutual labels:  geospatial, gis, shapefile
Blendergis
Blender addons to make the bridge between Blender and geographic data
Stars: ✭ 4,642 (+3971.93%)
Mutual labels:  geospatial, gis, shapefile
Geotools
Official GeoTools repository
Stars: ✭ 1,109 (+872.81%)
Mutual labels:  geospatial, gis, shapefile
localtileserver
🌐 dynamic tile server for visualizing rasters in Jupyter with ipyleaflet or folium
Stars: ✭ 190 (+66.67%)
Mutual labels:  geospatial, gis
PyTunes
A lightweight music player made in Python
Stars: ✭ 38 (-66.67%)
Mutual labels:  pyqt5, pyqt
gis-snippets
Some code snippets for GIS tasks
Stars: ✭ 45 (-60.53%)
Mutual labels:  gis, shapefile
gisjogja
GISJOGJA - aplikasi web based sistem informasi geografis (SIG) / GIS wisata kota JOGJA - www.firstplato.com
Stars: ✭ 17 (-85.09%)
Mutual labels:  gis, geographical-information-system
Stackoverflow
my answers in Stack Overflow
Stars: ✭ 211 (+85.09%)
Mutual labels:  pyqt5, pyqt
olturf
A Turf toolbar for OpenLayers.
Stars: ✭ 30 (-73.68%)
Mutual labels:  geospatial, gis
pygeopackage
A Python package to read/write spatial data to a geopackage.
Stars: ✭ 33 (-71.05%)
Mutual labels:  geospatial, gis
QtPyConvert
An automatic Python Qt binding transpiler to the Qt.py abstraction layer.
Stars: ✭ 66 (-42.11%)
Mutual labels:  pyqt5, pyqt
topo
A Geometry library for Elixir that calculates spatial relationships between two geometries
Stars: ✭ 125 (+9.65%)
Mutual labels:  geospatial, gis
15-minute-apps
15 minute (small) desktop apps built with PyQt
Stars: ✭ 3,469 (+2942.98%)
Mutual labels:  pyqt5, pyqt
python-kaynaklari
Python Türkiye Facebook sayfasında başlatılan projenin yeni sayfası
Stars: ✭ 30 (-73.68%)
Mutual labels:  pyqt5, pyqt
dekart
GIS Visualisation for Amazon Athena and BigQuery
Stars: ✭ 131 (+14.91%)
Mutual labels:  gis, gis-data
de9im
DE-9IM spatial predicate library implemented in Javascript.
Stars: ✭ 22 (-80.7%)
Mutual labels:  geospatial, gis
totalopenstation
Total Open Station downloads and exports survey data from your total station
Stars: ✭ 51 (-55.26%)
Mutual labels:  geospatial, gis
EOmaps
A library to create interactive maps of geographical datasets
Stars: ✭ 193 (+69.3%)
Mutual labels:  geospatial, gis

Introduction

A Geographic Information System (GIS) software is a software designed to import, analyze and visualize geographic data. PyGISS is a lightweight GIS software implemented both in tkinter and pyQt. Users can display maps using any type of projection and create objects either by importing an Excel file containing GPS coordinates, or with a Drag & Drop system.

pyGISS demo

PyGISS versions

Standard version (pyGISS.py, < 100 lines)

pyGISS

The standard version implements PyGISS in less than 100 lines of code.

It contains:

  • a menu 'Import shapefile' for the user to choose a shapefile and draw the map.
  • a menu 'Switch projection' to switch between the mercator and azimuthal orthographic projection.

The following bindings are implemented:

  • the scroll wheel can be used for zooming in and out.
  • pressing the left-click button on the map will print the associated geographical coordinates (longitude, latitude).

A few shapefiles are available for testing in the 'PyGISS/shapefiles' folder (world countries, continents, US).

Extended version (extended_pyGISS.py, < 500 lines)

extended pyGISS

In the extended version, besides the import of shapefiles, nodes can be created with a "Drag & Drop" system, moved on the map, resized, and deleted. They can also be imported by creating an Excel file that contains the longitude and latitude of the nodes. (an example is available in the 'PyGISS/projects' folder).

Golf version (golf_pyGISS.py, 5 lines)

pyGISS

The golf version implements the core feature of PyGISS (import and drawing of shapefiles + zoom system) in 5 lines of code.

How it works

A point on the earth is defined as a longitude and a latitude. Longitude and latitude are angles.

pyGISS

We need to convert a point on a sphere (3D) into a point on a map (2D). This is called a "projection". According to the remarkable theorem, a projection always causes a distortion (distances, shapes, areas, and/or directions are not preserved). For example, the Mercator projection preserves angles but fails to preserve area.

pyGISS

To convert geographic coordinates (longitude and latitude) into projected coordinates (planar coordinates), we use a library called pyproj.

pyGISS

The first thing that we need to create a GIS software is a GUI programming framework. There are many such frameworks in Python: tkinter, PyQt, pyside, wx_python, pyGTK, etc. pyGISS is implemented on two different frameworks: tkinter and pyQt.

Once we've chosen a framework, we need a widget that supports the drawing of 2D graphical items. In tkinter, this widget is called a Canvas; in pyQt, it is a QGraphicsView.

This widget has functions to create rectangles, circles, and most importantly, polygons. Indeed, as demonstrated below with Italy, a map can be represented as a set of polygons.

pyGISS

To draw the polygons, we need their coordinates. A shapefile (.shp) is a file that describes vector data as a set of shapes. For a map, there are two types of shapes: polygons and multipolygons. Polygons and multipolygons are defined as a set of points (longitude, latitude) on the earth.

pyGISS

To read the shapefile and extract the shapes it contains, we will use the pyshp library. Once this is done, we have a set of shapes, polygons and mutipolygons.

pyGISS

We can draw polygons with the GUI framework polygon function. A multipolygon is actually composed of multiple polygons. To draw a multipolygon, we will decompose it into the polygons it is made of with the shapely library.

pyGISS

The resulting algorithm is:

- Use pyshp to read the shapefile
- Extract the shapes of the shapefile
- When a shape is a multipolygon, decompose it into multiple polygons with shapely
- Use pyproj to convert the shape's geographic coordinates into projected coordinates
- Use the GUI framework method to draw the polygons

Below is the algorithm implemented with the pyQt framework:

def draw_polygons(self):
    # create a Proj projection: we will use it later the convert longitudes and 
    # latitudes into projected coordinates
    # The EPSG 3395 code corresponds to the Mercator projection
    pyproj_projection = pyproj.Proj(init="epsg:3395")
    
    # use the pyshp library to open the shapefile
    shapefile = shapefile.Reader(self.shapefile)
    
    # extract all the shapes it contains
    polygons = shapefile.shapes() 
    
    for polygon in polygons:
        
        # convert shapefile geometries into shapely geometries
        # to extract the polygons contained in multipolygons
        polygon = shapely.geometry.shape(polygon)
        
        # if it is a polygon, we use a list to make it iterable
        if polygon.geom_type == 'Polygon':
            polygon = [polygon]
            
        for land in polygon:
            qt_polygon = QPolygonF()
            for lon, lat in land.exterior.coords:  
                # use the pyproj projection to convert geographic coordinates
                # into projected coordinates
                px, py = pyproj_projection(lon, lat)
                
                # if it's out of the map (for example for an azimuthal 
                # orthographic projection), ignore it
                if px > 1e+10:
                    continue
                qt_polygon.append(QPointF(px, py))
                
            # create the pyQt graphical item and return it
            yield QGraphicsPolygonItem(qt_polygon)

PyGISS dependencies

PyGIS relies on three Python libraries:

  • pyshp, used for reading shapefiles.
  • shapely, used for converting a multipolygon into a set of polygons
  • pyproj, used for translating geographic coordinates (longitude and latitude) into projected coordinates

Before using PyGISS, you must make sure all these libraries are properly installed:

pip install pyshp
pip install shapely
pip install pyproj

For the Qt version of pyGISS, pyQt5 is required: it can be download from the Riverband website

For the tkinter version of the extended PyGISS, Pillow (ImageTk) is required: it can be installed directly via pip.

sudo apt-get install python3-tk (unix)
sudo apt-get install python3-pil.imagetk (unix)
pip install pillow (windows & unix)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].