Package: karta
KartaKartais a package for spatial analysis in Python. It simplifies
geospatial data processing by providing efficient generic classes for
vector and raster data sources, as well as a selection of analysis
functions.Vector data typesData are represented asPoint,Line,Polygon,Multipoint,Multiline, andMultipolygoninstances.All data contain a.crsmember encoding coordinate reference
information. All vector geometries possess a.propertiesdict
containing free-form metadata.Multipartgeometries additionally
possess a.datamember which is a simple typed table-like data
structure.Geometries implement methods for computing distances, directions, and
spatial characteristics.Multipartgeometries support fast spatial
indexing through quadtrees and r-trees.GeoJSON and ESRI shapefile formats are supported for reading and
writing. Experimental support for GPX XML files is in thekarta.vector.gpxsubmodule.Vector geometries implement the Python`__geo_interface__attribute <https://gist.github.com/sgillies/2217756>`__ for vector
geometries. This permits data to be exchanged betweenKartaand
external modules that also implement__geo_interface__(e.g.shapely,fastkml).Raster data typesThe primary raster data type is theRegularGrid, which represents
one or more 2-d arrays of pixels spaced via an affine transformation.RegularGridsare backed by one of severalBandimplementations,
with the default implementation using theblosccompression library for efficient
in-memory storage. There is experimental support for disk-backed storage
via GDAL.Grids may be queried, resampled, sliced, masked, and merged. Arbitrary
array-based functions may be mapped to raster data withRegularGrid.apply(). Raster functions including slope, gradient, and
hillshade are in thekarta.raster.miscsubmodule.GeoTIFF images are the primary supported format, however ESRI ASCII
grids may also be used (with limitations due to the format).Coordinate reference systemsData in Karta is referenced to positions on earth viaCRSobjects
that implement projection and geodetic methods. Coordinate reference
systems may be either geographical or projected.Geographical CRSobjects return spatial relationships in terms of
the true computed distances and azimuths on a spherical or ellipsoidal
Earth.Projected CRSobjects (e.g. UTM, Polar Stereographic, and Web
Mercator) return spatial relationships in terms of a flat plane,
dependent on the projection.ExamplesRead 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 unitsline.intersects(polygon)# True or Falsech=polygon.convex_hull()# Returns a new polygonch.to_shapefile("poly.shp")Load and manipulate raster data:grid=read_gtiff("landsat_scene.tif")# Leverages GDALgrid.profile(line)# Collect data along a linegrid.resample(500.0,500.0)# Return a grid resampled at a new resolutionInstallationKartacurrently supports Python 2.7 and Python 3.4+.The easiest way to install is viapip. Installation requires a recent
version ofsetuptools.pip install -U setuptools
pip install kartaBuilding from sourceBuilding from source requires Cython and a C99-compliant compiler:pip install CythonThen, clone the repository and install:git clone https://github.com/fortyninemaps/karta.git karta
cd karta/
python setup.py buildDocumentationSee theonline
manual,
thetutorial,
or read theAPI
documentation.ContributingBug reports, feature requests, and pull requests are welcome.Run unit tests withpython tests/runtests.py.The manual is built usingSphinxand
requiresnumpydoc.