Geospatial & Geophysics
Learn Python through explicit geospatial models: coordinates, spherical distances, projections, planar geometry, spatial indexes, raster terrain, interpolation, spatial statistics and simplified seismic calculations. Finish by composing a testable MiniGIS layer-to-decision pipeline.
11 projects, 275 hands-on levels, run in your browser.
Syllabus
- Foundations: code through maps: Never written code before? Start here. You will learn the basics of Python, output, variables, types, decisions, loops, and functions, through coordinates, distances, and maps. By the end you are ready for Project 1.
- Coordinates & the Earth: Every map starts with a pair of numbers: latitude and longitude. This project builds fluency with them, validating and normalizing coordinates, converting between degrees-minutes-seconds and decimal degrees, working with bounding boxes, and measuring the spherical Earth itself, how long a degree really is, and why that depends on where you stand.
- Distance & Geodesics: Use a 6371-km sphere for great-circle distances, bearings and destinations. Compare these with explicitly local planar route calculations, then summarize GPS lengths, speeds and elapsed time, including stops.
- Map Projections: Build spherical equirectangular and Mercator formulas, a common XYZ Web Mercator tile scheme, and simple distortion calculations. Keep angular projection coordinates, metres and screen pixels distinct; choose a model for the intended use.
- Vector Geometry: Build planar single-ring point tests, shoelace area and centroid, proper-crossing predicates, supporting-line intersections and gift-wrapping hulls. Study an explicitly infinite-line-distance simplification variant; these exercises are not complete polygon-validity or general GIS geometry implementations.
- Spatial Indexing: Build grids, geohashes, a bounded quadtree and a small bounding-box hierarchy. Separate candidate windows and approximate nearest lookup from exact queries. Count modeled work without inferring measured speed, and retain observations at cell boundaries and duplicate coordinates.
- Rasters & DEMs: Georeference a north-up raster, sample values, calculate signed finite differences and illuminate terrain with a consistent sun/normal convention. Explore lowest-neighbor flow and one-pass strict-pit filling as simplified terrain exercises, not full D8 hydrology.
- Spatial Interpolation: Compare nearest, inverse-distance and triangular interpolation on finite planar samples. Grid predicted fields and use leave-one-out errors to choose candidate powers. Parameter tuning and independent final performance assessment are separate steps.
- Spatial Analysis: Count planar buffers, join points to simple rings, grow DBSCAN clusters and form raw conical intensity surfaces. Calculate a specified rook-weight Moran statistic; toy interpretation labels do not establish statistical significance or randomness.
- Seismology & Geophysics: Use constant-speed travel times and a planar grid-search location model, illustrative magnitude calculations and energy-window triggers. Distinguish these teaching models from calibrated seismic inversion, phase identification and hazard assessment.
- Capstone: A Mini GIS Engine: Assemble a testable MiniGIS facade over validated internal Point layers. Build conservative grid candidates, run exact bbox/radius/polygon filters and global nearest scans, report local-layer analytics, and execute eligibility-first site selection. Convert supported internal records explicitly to GeoJSON; no map UI, GIS-compliance or speed guarantee is implied.
Key concepts
- 2D cross product: The signed area test (b-a) x (c-a): positive means a left turn, negative a right turn, zero collinear. The primitive under hulls, intersections, and orientatio…
- Antipode: The point exactly opposite a location through the center of the Earth: negate the latitude and shift the longitude by 180 degrees.
- Aspect: Downhill direction. With north-positive gy and east-positive gx, compass aspect is atan2(-gx,-gy); mathematical azimuth for hillshade is atan2(-gy,-gx). A flat…
- Barycentric coordinates: Three signed area-ratio weights summing to one for a point relative to a nondegenerate triangle. Nonnegative weights describe the closed triangle; negative wei…
- Bearing: Direction measured clockwise from north. Initial bearing is the departure direction at the first point; the forward bearing generally varies along a great-circ…
- Bilinear interpolation: Interpolation in a rectangular cell using four product weights (1-fx)(1-fy), fx(1-fy), (1-fx)fy and fx*fy. It reproduces the corners and retains the value unit…
- Bounding box: An axis-aligned enclosing rectangle, often (min_lon,min_lat,max_lon,max_lat) for a non-wrapping geographic extent. Box overlap is a candidate test rather than…
- Buffer: A region within a specified distance of a feature under a stated metric. A planar point buffer is a disk; a polygon approximation samples its boundary. Geograp…
- Centroid: Center of mass of a uniform planar polygon, calculated from signed edge cross products and nonzero area. It may lie outside a concave polygon, so it is not alw…
- Choropleth: A map that shades regions by an aggregated value, incidents per district, income per county. Built from a spatial join plus a group-by.
- Convex hull: Smallest convex set containing the input points. Gift wrapping walks its extreme vertices; collinear ties choose the farthest point. Empty, singleton and colli…
- Cross-track distance: Signed distance from a point to a specified oriented great-circle route in the spherical formula. Planar distance to a finite route segment is a different calc…
- DBSCAN: Density clustering with an inclusive eps neighborhood and minimum count. Core points expand clusters, noncore border points may join them, and observations unr…
- Degrees-minutes-seconds (DMS): The traditional coordinate notation: 48 degrees 51 minutes 24 seconds. Converted to decimal degrees as d + m/60 + s/3600, negated for south and west.
- Digital elevation model (DEM): A raster of terrain heights. The substrate for slope, aspect, hillshade, viewsheds, and hydrology.
- Douglas-Peucker: Recursive line simplification retains endpoints and splits at the farthest interior point when its distance exceeds a tolerance. The taught variant measures in…
- Epicenter: Surface location above an earthquake hypocenter. The course estimates a point in a simplified 2D constant-speed setting; a real seismic inversion must account…
- Equal-area projection: A projection preserving relative area under its specified Earth model, with shape or angle distortion. It supports area comparison and aggregation when measure…
- Equirectangular projection: The simplest projection: longitude becomes x, latitude becomes y. Cheap and fine near a chosen standard parallel, increasingly stretched elsewhere.
- Feature: A geometry plus its attributes (properties): a school with its name, a parcel with its owner. The unit of vector GIS data.
- Flow direction (D8): D8 convention chooses maximum elevation drop divided by neighbor distance among eight neighbors. The course helper instead chooses the lowest neighboring eleva…
- Generalization: Simplifying geometry for a smaller scale: fewer vertices, merged features, dropped detail. What keeps a world map from carrying a centimeter coastline.
- Geodesic: A locally straight path on a curved surface. A sufficiently short minimizing geodesic joins points by a shortest path. On a sphere these paths follow great cir…
- Geohash: A string encoding alternating longitude/latitude bisections. Shared prefixes identify a common coarse cell. Nearby points across cell boundaries may have diffe…
- GeoJSON: The web's standard format for geographic features: geometries (Point, LineString, Polygon) plus properties, bundled into FeatureCollections. Coordinates ar…
- Geotransform: Mapping between raster indices and world coordinates. General affine transforms may include rotation and different x/y scales. This course uses a north-up grid…
- GPS trace: A sequence of timestamped position fixes. Real traces carry noise and teleporting glitches; cleaning means speed filters and deduplication before any analysis.
- Great circle: Intersection of a sphere with a plane through its center. The shorter arc connects non-antipodal points by a shortest spherical surface path; ellipsoidal geode…
- Gutenberg-Richter law: Empirical relation log10 N(M>=m)=a-b*m over an appropriate magnitude range. With b about 1, lowering the threshold by 1 gives roughly ten times as many even…
- Haversine formula: A spherical distance formula using radians: a=sin²(dlat/2)+cos(lat1)cos(lat2)sin²(dlon/2), d=2R*asin(sqrt(a)). Clamp floating a to [0,1] before inverse trigono…
- Hillshade: Synthetic terrain lighting: shade each cell by how squarely it faces a virtual sun (cos of the angle between surface normal and light). What makes flat maps lo…
- Hotspot: A region of high observed intensity or a cluster under stated parameters. A KDE peak or DBSCAN cluster alone does not establish statistical significance; that…
- Inverse distance weighting (IDW): Inverse-distance weighting uses weights proportional to 1/d^p for positive p. Increasing p gives closer samples more relative influence. Handle exact hits befo…
- Kernel density estimation (KDE): A kernel sum forms a smooth intensity surface; normalization determines whether it represents density and in what units. The course uses raw conical sums with…
- Latitude: Angular position north or south of the equator, from -90 to +90 degrees. On the 6371-km spherical model, a degree spans about 111.195 km along a meridian; elli…
- Layer: A named collection of features of the same kind (all schools, all roads). A GIS engine manages, indexes, and queries layers.
- Leave-one-out cross-validation: Hold samples out, predict without them and summarize errors, for example with RMSE. Leave-one-out tuning estimates performance on those folds; spatial dependen…
- Longitude: Angular position east or west of the reference meridian. On a sphere, a degree measured along a parallel spans R pi/180 cos(latitude). A canonical interval suc…
- Magnitude: A logarithmic earthquake-size measure. A one-unit local-magnitude difference corresponds to a tenfold standardized amplitude ratio; a commonly used approximate…
- Map matching: Snapping noisy GPS fixes onto the road network: find the nearest plausible segment for each fix. Built on point-to-segment distance.
- Map projection: A rule for flattening the curved Earth onto a plane. Every projection distorts something, distance, area, or angle; choosing one means choosing which lie you c…
- Mercator projection: A conformal projection preserving local angles. On a unit sphere x=longitude radians and y=log(tan(pi/4+latitude/2)); linear scale is sec(latitude). Rhumb line…
- Moran's I: A global spatial-autocorrelation statistic: (N/W) sum(w_ij z_i*z_j)/sum(z_i²). Its attainable bounds depend on weights and values; positive or negative values…
- Nearest neighbor: The observation minimizing a declared distance, with an explicit tie policy. A fixed neighborhood can omit the true nearest; exact indexed search needs a compl…
- NoData value: A sentinel or mask marking missing measurements. Exclude missing values from appropriate computations. A finite sentinel uses inequality; NaN requires an expli…
- P wave: A compressional body wave, usually the earliest body-wave arrival. The course uses VP=6 km/s as a constant teaching value; real travel speeds and paths depend…
- Point in polygon: A containment question for a point and polygon. Ray parity handles concave simple rings away from boundaries; edge, vertex, hole and invalid-ring policies must…
- Quadtree: A tree partitioning a planar box into four children. This course splits crowded leaves when possible, but retains over-capacity leaves for coincident points, n…
- R-tree: A hierarchy grouping spatial entries beneath enclosing rectangles. Intersecting boxes identify candidates for exact predicates. The course uses a small packed…
- Raster: Geography as a grid of cells, each holding a value: elevation, imagery, land cover. Cheap to process per-cell, heavy to store, the complement of vector data.
- Ray casting: The point-in-polygon algorithm: shoot a horizontal ray to infinity and toggle inside/outside at every edge it crosses.
- Resampling: Reading a raster at positions between cells: nearest-neighbor snaps (blocky but value-preserving), bilinear blends the four neighbors (smooth).
- Rhumb line: A path of constant compass bearing, represented by a straight line on a Mercator chart. It is generally longer than the shortest great-circle route between the…
- S wave: A shear wave, generally slower than P waves and unable to propagate through liquids. This course assumes 3.5 km/s for calculations; real velocities, amplitudes…
- S-minus-P time: S arrival minus P arrival. Under shared path length and constant speeds, distance=gap/(1/vs-1/vp). This estimates path length, not direction or generally horiz…
- Segment intersection: Proper crossings require opposite nonzero orientation signs on both supporting lines. A full segment-intersection predicate also handles collinear overlap and…
- Seismogram: A recorded time series from a seismic instrument. Values may require response correction and calibration before they represent physical ground motion. Demeanin…
- Shoelace formula: For a simple planar ring, half the absolute wrapped sum of x_i y_next-x_next y_i gives area in squared coordinate units. The signed sum indicates winding for x…
- Slope: Terrain angle atan(hypot(dz/dx,dz/dy)). Derivatives are ratios, and elevation and horizontal cell size must use compatible length units. Central differences es…
- Spatial autocorrelation: Association between values at locations linked by a chosen spatial-weight matrix. Its sign and magnitude depend on the data and weights; spatial proximity does…
- Spatial index: A structure organizing geometry or observations so a query can examine relevant candidates. Exact results require a conservative candidate set and final predic…
- Spatial interpolation: Estimating a field everywhere from samples somewhere: nearest, IDW, splines, TINs, kriging. Turning forty stations into a full surface.
- Spatial join: Attach or aggregate attributes using a spatial relation such as containment or proximity. One point may match multiple polygons; the course first-match join us…
- STA/LTA: Ratio of short- and long-window average signal energy. A threshold crossing is an event trigger, not automatic P/S identification. Window definitions, scale, d…
- Tile pyramid: The zoom hierarchy of web maps: zoom 0 is one tile for the world, and each level quadruples the tile count (2^z per side). A tile is addressed as z/x/y.
- Triangulated irregular network (TIN): Samples connected into triangles; values interpolate linearly inside each via barycentric coordinates. Exact at samples and piecewise-planar between them.
- Trilateration: Location from distances to known stations. Three suitably placed stations can constrain a 2D point; inconsistent distances, poor geometry and unknown depth com…
- Vector data: Geography stored as geometry: points, lines, and polygons with coordinates. The counterpart of raster data, which stores a grid of values.
- Voronoi diagram: Partition by a declared nearest-site distance. Boundaries contain equal-distance ties and need a policy when assigning one sample. Euclidean Voronoi cells are…
- Watershed: The area whose water drains to a common outlet, delineated by following flow directions upstream. The fundamental unit of hydrology.
- Web Mercator: A widely used web-mapping projection and tiling convention. A square world clips latitude at about 85.05112878 degrees. Tile size, zoom convention and Earth-ra…
- Winding order: The direction a polygon's vertices march: counter-clockwise gives positive signed area. GeoJSON wants exterior rings counter-clockwise and holes clockwise.
- Zoom level: Level of a tile pyramid. For a 256-pixel world tile and radius 6378137 m, nominal ground resolution is approximately 156543.03*cos(latitude)/2^z metres per pix…