https://github.com/satellogic/telluric-talks
Geospatial data, geographic data, georeferenced data, or just geodata "are defined in the ISO/TC 211 series of standards as data and information having an implicit or explicit association with a location relative to the Earth"
-- https://en.wikipedia.org/wiki/Geographic_data_and_information
A geographic information system (GIS) is a system designed to capture, store, manipulate, analyze, manage, and present spatial or geographic data.
-- https://en.wikipedia.org/wiki/Geographic_information_system
Image by Víctor Olaya "Sistemas de Información Geográfica", CC-BY
Image by M. W. Toews https://en.wikipedia.org/wiki/File:Simple_vector_map.svg, CC-BY
A method to locate points on earth
TL;DR: A mess.
The landscape is complicated and somewhat difficult to navigate at times:
Summary of key libraries:
Python | C/C++ | |
---|---|---|
pyproj | ⇒ | PROJ.4 |
Fiona | ⇒ | OGR |
Shapely | ⇒ | GEOS |
rasterio | ⇒ | GDAL |
telluric is an open source (MIT) Python library to manage vector and raster geospatial data in an interactive and easy way.
Importing for interactive use is short:
import telluric as tl
from telluric.constants import WGS84_CRS, WEB_MERCATOR_CRS
Basic geometry definition using GeoVector
: in the simplest case, the bounds and the projection (CRS)
gush_dan = tl.GeoVector.from_bounds(
xmin=34.6, ymin=32, xmax=35.0, ymax=32.3, crs=WGS84_CRS
)
print(gush_dan)
GeoVector(shape=POLYGON ((34.6 32, 34.6 32.3, 35 32.3, 35 32, 34.6 32)), crs=CRS({'init': 'epsg:4326'}))
gush_dan
/home/guyd/pEnvs/telluric-dev/local/lib/python3.5/site-packages/telluric/plotting.py:141: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization "Plotting a limited representation of the data, use the .plot() method for further customization")
Using Shapely geometries is also allowed:
from shapely.geometry import Polygon
south_tlv = tl.GeoVector(
Polygon([(34.75, 32.04), (34.75, 32.06), (34.77,32.06), (34.77, 32.04), ( 34.75, 32.04)]),
WGS84_CRS
)
south_tlv
/home/guyd/pEnvs/telluric-dev/local/lib/python3.5/site-packages/telluric/plotting.py:141: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization "Plotting a limited representation of the data, use the .plot() method for further customization")
gush_dan.centroid
/home/guyd/pEnvs/telluric-dev/local/lib/python3.5/site-packages/telluric/plotting.py:141: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization "Plotting a limited representation of the data, use the .plot() method for further customization")
gush_dan.area # Real area in square meters
1259014132.9260154
gush_dan.within(south_tlv)
False
south_tlv.within(gush_dan)
True
print(south_tlv.difference(gush_dan))
GeoVector(shape=GEOMETRYCOLLECTION EMPTY, crs=CRS({'init': 'epsg:4326'}))
gush_dan.difference(south_tlv)
/home/guyd/pEnvs/telluric-dev/local/lib/python3.5/site-packages/telluric/plotting.py:141: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization "Plotting a limited representation of the data, use the .plot() method for further customization")
GeoVector
+ attributesFeatureCollection
s: a sequence of featuresgf1 = tl.GeoFeature(
gush_dan,
{'district': 'גוש דן'}
)
gf2 = tl.GeoFeature(
south_tlv,
{'city': 'תל אביב'}
)
print(gf1)
print(gf2)
GeoFeature(Polygon, {'district': 'גוש דן'}) GeoFeature(Polygon, {'city': 'תל אביב'})
fc = tl.FeatureCollection([gf1, gf2])
fc
/home/guyd/pEnvs/telluric-dev/local/lib/python3.5/site-packages/telluric/plotting.py:141: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization "Plotting a limited representation of the data, use the .plot() method for further customization")
# This will only save the URL in memory
rs = tl.GeoRaster2.open(
"https://github.com/mapbox/rasterio/raw/master/tests/data/rgb_deflate.tif"
)
# These calls will fecth some GeoTIFF metadata
# without reading the whole image
print(rs.crs)
print(rs.band_names)
CRS({'init': 'epsg:32618'}) [0, 1, 2]
rs.footprint() # is the bouding box
/home/guyd/pEnvs/telluric-dev/local/lib/python3.5/site-packages/telluric/plotting.py:141: UserWarning: Plotting a limited representation of the data, use the .plot() method for further customization "Plotting a limited representation of the data, use the .plot() method for further customization")
rs