Skip to main content

NSG Common Python Library

Project description

NSG Common Library

NSG common library.

A Python 3 library that contains the basic objects and schemas that NSG tile caches, or NSG components would need to adhere to.

Motivation

We wanted a library to contain common geospatial objects and commonly used functions to be used acrossed NSG python geospatial libraries and tools.

Build status

pipeline status coverage report

Sample Code

Example of calculating resolution width and height:

from nsg.common.spatial_reference_system import SpatialReferenceSystem
from nsg.tile_cache.tile_scheme import calc_resolutions

resolution_width, resolution_height = calc_resolutions(bounding_box=SpatialReferenceSystem.NSG_WORLD_GEODETIC.world_bounding_box,
                                                       tile_size=(256, 256),
                                                       zoom_level=1,
                                                       tile_scheme=SpatialReferenceSystem.NSG_WORLD_GEODETIC.tile_scheme)

Installation

pip install nsglib

Common NSG objects

Some examples of NSG objects include (but not limited to):

  • SpatialReferenceSystem
  • BoundingBox
  • Coordinate

The most common Spatial Reference Systems that are defined are EPSG:4326, EPSG:3395, and EPSG:3857. These Spatial Reference Systems can be easily accessed by using the Python Enum: SpatialReferenceSystem.NSG_WORLD_GEODETIC, SpatialReferenceSystem.NSG_WORLD_MERCATOR, SpatialReferenceSystem.WEB_MERCATOR

The bounding box defines an object that holds the extent information in a particular Coordinate Reference System.

A Coordinate is an geographical location on a map. They can be used for Coordinate Reference System coordinates or tile coordinates.

Tile Cache NSG Objects

Some examples of Tile Cache objects include(but not limited to):

  • Tile
  • TileScheme
  • AbstractTileCache

A Tile has a coordinate location (row, colum, zoom level) and a source. The coordinate location describes where to place the tile. The source is the tile data in bytes (the jpeg, png, or vector-tile data).

A Tile Scheme is how the world is divided up into tiles based on zoom level. There is also an implementation included called ZoomTimesTwo which is a tile scheme implementation of a common convention where a tile set's tile matrix doubles width and height between successive zoom levels.

Tile Scheme class also includes functions for calculating the resolution and scale denominator.

An AbstractTileCache are the basic functions that a tile cache should include. Some example tile caches are Compact Cache V2, GeoPackage, and File based Cache.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nsglib-3.0.0.0.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

nsglib-3.0.0.0-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page