Skip to main content

Geospatial analysis in Python

Project description

Karta is a package for spatial analysis in Python. It streamlines data processing by providing efficient generic geographical types for vector and raster sources as well as a selection of analysis functions.

For example, read or create vector geometries:

point = Point((-130.0, 52.0), crs=LonLatWGS84)
line = read_geojson("linedata.json")
polygon = Polygon([(-515005.78, -1301130.53),
                   (-579174.89, -1282271.94),
                   (-542977.83, -1221147.82),
                   (-437864.05, -1251641.55),
                   (-438160.72, -1252421.48),
                   (-437961.28, -1285314.00)],
                   crs=NSIDCNorth)

Perform simple queries:

point2 = Point((-25.0, 48.0), crs=LonLatWGS84)
point.distance(point2)          # Distance in geographical units
line.intersects(polygon)        # True or False
ch = polygon.convex_hull()      # Returns a new polygon
ch.to_shapefile("poly.shp")

Load and manipulate raster data:

grid = read_gtiff("landsat_scene.tif")  # Leverages GDAL
grid.profile(line)              # Collect data along a line
grid.resample(500.0, 500.0)     # Return a grid resampled at a new resolution

Documentation

See the online manual, the tutorial, or read the API documentation.

The manual can be built offline using Sphinx. Building the documentation requires numpydoc.

Package Overview

  • karta.crs: framework for coordinate reference systems and geodetic calculations

  • karta.vector.geometry: geometry classes Point, Multipoint, Line, and Polygon with associated methods such as length, area, intersections, membership testing, convex hulls, and affine transformations

  • karta.raster.grid: Grid classes including RegularGrid class (supporting CRS-aware clipping, sampling, profiling along vector tracks), and experimental WarpedGrid

  • tests: unit tests, to be run with python tests/runtests.py

Formats

Karta provides a basic working interface to several of common file formats. Currently implemented are:

  • vector

    • GeoJSON (r,w)

    • ESRI Shapefiles (via GDAL) (r,w)

    • GPS eXchange (GPX) (r,w)

  • raster

    • GeoTiff (via GDAL) (r,w)

    • ESRI ASCII Grid (r,w)

Karta implements the Python `__geo_interface__ attribute <https://gist.github.com/sgillies/2217756>`__ for vector geometries. This permits data to be exchanged between Karta and external modules that also implement __geo_interface__ (e.g. shapely, fastkml).

Installation

The easiest way to install in production is via pip. Installation requires a recent version of setuptools:

pip install -U setuptools

Then, to install the latest release from PyPI:

pip install karta

Building from source

Building from source requires Cython:

pip install Cython

Then, clone the repository and install:

git clone https://github.com/fortyninemaps/karta.git karta
pip install -r karta/requirements.txt
pip install karta/

Dependencies

  • numpy >= >1.7

  • gdal >= 1.10

  • pyproj >= 1.9

  • blosc >= 1.2

  • C99-compliant compiler

Karta supports Python 2.7 and Python 3.4+.

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

karta-0.7.1.tar.gz (848.1 kB view details)

Uploaded Source

File details

Details for the file karta-0.7.1.tar.gz.

File metadata

  • Download URL: karta-0.7.1.tar.gz
  • Upload date:
  • Size: 848.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for karta-0.7.1.tar.gz
Algorithm Hash digest
SHA256 62258748c6e71bdeabe0ddd1e6a5a90163ecf4addfcd48f34fdaff5d92392000
MD5 6603cb35327b4d19fa4f2bb7d57705da
BLAKE2b-256 983987a9ab95864268ac0d1631ebdc18e6af3de8ea711d4ccc015e673b4a55c0

See more details on using hashes here.

Supported by

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