{"id":17204408,"url":"https://github.com/urschrei/geopython","last_synced_at":"2025-05-16T09:06:44.223Z","repository":{"id":19198416,"uuid":"22431796","full_name":"urschrei/Geopython","owner":"urschrei","description":"Notebooks and libraries for spatial/geo Python explorations","archived":false,"fork":false,"pushed_at":"2025-02-02T20:14:48.000Z","size":82214,"stargazers_count":358,"open_issues_count":0,"forks_count":67,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-04-09T04:04:42.692Z","etag":null,"topics":["basemap","choropleth","computational-geometry","geo","geographical-information-system","geographically-weighted-regression","geopandas","geospatial","isochrones","jupyter","matplotlib","pandas","rust","shapely","spatial-analysis"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/urschrei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-30T14:44:43.000Z","updated_at":"2025-04-06T08:29:42.000Z","dependencies_parsed_at":"2025-03-18T16:32:29.594Z","dependency_job_id":null,"html_url":"https://github.com/urschrei/Geopython","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urschrei%2FGeopython","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urschrei%2FGeopython/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urschrei%2FGeopython/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/urschrei%2FGeopython/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/urschrei","download_url":"https://codeload.github.com/urschrei/Geopython/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501558,"owners_count":22081528,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["basemap","choropleth","computational-geometry","geo","geographical-information-system","geographically-weighted-regression","geopandas","geospatial","isochrones","jupyter","matplotlib","pandas","rust","shapely","spatial-analysis"],"created_at":"2024-10-15T02:21:47.940Z","updated_at":"2025-05-16T09:06:39.212Z","avatar_url":"https://github.com/urschrei.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Geocomputation, Cartography, and Spatial Analysis Techniques Using Python\n\n[![Tweetcity](https://github.com/urschrei/CityEngine-Twitter/blob/master/london.png)](http://urschrei.github.io/CityEngine-Twitter/ \"Tweet\")\n\nThis is a repository of various geo/spatial analysis techniques using Python libraries, chiefly Numpy, Pandas, Shapely, Fiona, Descartes, Matplotlib, and Matplotlib-Basemap.\n\nThese tutorials, visualisations, and libraries are an occasional side effect of being embroiled in a PhD at the [Bartlett Centre for Advanced Spatial Analysis](http://www.bartlett.ucl.ac.uk/casa), at [UCL](http://www.ucl.ac.uk), and teaching on the undergraduate [Data Science and Visualisation](http://www.ucl.ac.uk/basc/prospective/core/qm2/#tabs-2) course.\n\n[![CASA](data/casa_black.png)](http://www.bartlett.ucl.ac.uk/casa/programmes/postgraduate \"Bloomsbury is lovely, you know.\")\n\n### The Notebooks\n\n[![Hovertube](https://github.com/urschrei/hovertube/blob/master/tube.png)](https://github.com/urschrei/hovertube \"Ghostly. vv ghostly\").  \nProcess TfL tube and rail data, and display it using Mapbox GL JS\n\n[![Inset](data/inset_gh.png)](isochrone.ipynb \"Yo Dawg\").  \nTfL bike rental travel time isochrone calculation\n\n[![Airbnb](https://github.com/urschrei/geopython/blob/master/rentals_gh.png)](https://github.com/urschrei/Geopython/blob/master/airbnb.ipynb \"All that is solid melts into air\")\n\n[Airbnb](https://github.com/urschrei/Geopython/blob/master/airbnb.ipynb): mapping Airbnb rental data in London\n\n[![Boroughs](https://github.com/urschrei/geopython/blob/master/boroughs_gh.png)](https://github.com/urschrei/Geopython/blob/master/airbnb.ipynb \"Can I borough a feeling\")\n\n[GWR](https://github.com/urschrei/Geopython/blob/master/geographically_weighted_regression.ipynb): An introduction to Geographically Weighted Regression using PySAL, using a worked example.\n\n[Convert](convert.ipynb): demonstrates point, choropleth, and hexbin mapping techniques using pandas and Matplotlib Basemap  \n\n[Convert_Folium](convert_folium.ipynb): demonstrates the use of the [Folium](https://github.com/wrobstory/folium) library for creating web-based maps from Python data (pandas) using [Leaflet](http://leafletjs.com) to generate a choropleth map\n\n[Router Comparison](https://github.com/urschrei/router_comparison): analyses route characteristics of journeys from the London Cycle Hire network centroid to 554 stations, calculated using [OSRM](https://mapzen.com/blog/osrm-sunset), Mapzen's new [Valhalla](https://mapzen.com/projects/valhalla/) router, and the [Google Maps Directions API](https://developers.google.com/maps/documentation/directions/intro). There's also some outlier identification using RANSAC, and hopefully useful wrappers for route retrieval in `helpers.py`.\n\n[![Routers](https://github.com/urschrei/router_comparison/blob/master/combined_gh.png)](https://github.com/urschrei/router_comparison \"IT'S CALLED VALHALLA. LIKE IN FURY ROAD. AAAAA. I LIVE. I DIE. I LIVE AGAIN!\")\n\n[WLS](https://github.com/urschrei/linalg/blob/master/notebooks/weighted_least_squares.ipynb): demonstrates the use of weighted least-squares estimation of similarity and affine transforms to calculate parameters for a transformation matrix which can be used to transform and align coordinates. This approach is useful for e.g. georeferencing raster data, and map feature alignment and correction.\n\n[![weighted](https://raw.githubusercontent.com/urschrei/linalg/master/WLS.png)](https://github.com/urschrei/linalg/blob/master/notebooks/weighted_least_squares.ipynb \"Weighty\")\n\n[Contour](contour.ipynb): demonstrates interpolation of irregularly-spaced point data (mean rainfall) into a regular grid, calculating a contour plot, and imposing it onto a basemap (see graphic below). Two approaches for calculating continuous surfaces are then compared – Delaunay Natural Neighbour (`matplotlib.griddata`), and refinement of a coarse Delaunay mesh using `matplotlib.UniformTriRefiner`, which uses recursive subdivision and cubic interpolation. High-res images are available in the [data](data) folder, all beginning with `rainfall_`. :umbrella::umbrella::umbrella:  \nFinally, the map is partitioned into *clipped* Voronoi cells based on the sensor locations, and some plotting methods (more flexible than `scipy.spatial.voronoi2d`) are shown.  \n\n[![Make it rain](data/rainfall_interpolation.gif)](contour.ipynb \"Anigifs are the future of spatial analysis\")\n\n[![Cellular](data/voronoi_gh.png)](https://raw.githubusercontent.com/urschrei/Geopython/master/data/voronoi.png \"Tesselate Everything\")\n\n[Bikepath](bikepath.ipynb): takes a subset of London bicycle hire stations, creates a DataFrame of all possible origin and destination pairs, and then uses MapZen's wonderful [open Valhalla endpoint](https://mapzen.com/projects/valhalla) to get valid bicycle routes between them. These routes are then plotted (it's just the first 400 – there are over 490k origin / destination pairs in total) on a map.\n\n[![Bikepath](data/london_bike_routes_gh.png)](bikepath.ipynb \"Unpleasantly vascular, no?\")\n\n[Isochrone](http://nbviewer.ipython.org/github/urschrei/Geopython/blob/master/isochrone.ipynb): an [isochrone](http://en.wikipedia.org/wiki/Isochrone_map) is computed for the complete London bike network from an origin at its centroid. Given a network of stations, [Single-Source Shortest Path Length](https://networkx.github.io/documentation/latest/reference/algorithms.shortest_paths.html), weighted by the travel time between the origin and destinations can be used to generate travel times – though this isn't necessary for a single origin.\n\n[![Isochrone](data/isochrone_gh.gif)](isochrone.ipynb \"The Burning Eye of Bike Hire\")\n\n[Plaques_Geopandas](plaques_geopandas.ipynb): demonstrates [Geopandas](http://geopandas.org) and its spatial join functionality, used to create a choropleth.\n\n[![Choropleth](data/london_plaque_density_gh.png)](http://sensitivecities.com/so-youd-like-to-make-a-map-using-python-EN.html \"Boropleth\")\n## Libraries\n[Circles](circles.ipynb)  \nDemonstrates drawing circles with correct distortion characteristics on a map (the dot-shaded circle is erroneously non-distorted). The helper library used to plot the circles is available [here](https://github.com/urschrei/Circles).\n\n[Lonlat-BNG](https://github.com/urschrei/lonlat_bng/blob/master/rust_BNG.ipynb)  \nA demonstration of writing a [Rust](http://www.rust-lang.org) library, and linking it to Python using FFI, in order to carry out fast Longitude and Latitude to British National Grid transformations, using multithreading. I've blogged about the process [here](http://sensitivecities.com/rust-python-ffi-bng-EN.html). The Python library is available [here](https://github.com/urschrei/convertbng).\n\n[Pypolyline](https://github.com/urschrei/pypolyline)  \nA Python library for encoding and decoding Google encoded polylines, using a Rust binary and FFI.\n\n[RDP](https://github.com/urschrei/rdp)  \nA Rust implementation of the Ramer–Douglas–Peucker line simplification algorithm. Includes an FFI wrapper.\n\n[Polylabel-rs](https://github.com/urschrei/polylabel-rs)  \nA Rust implementation of the Mapbox Polylabel algorithm, which determines optimum label placement on a polygon by calculating its pole of inaccessibility. The library has an FFI wrapper, and a sample Python script which demonstrates its use (I know Shapely also includes the algorithm, but it's a pure-Python implementation, and this one is…somewhat faster)\n\n[![Circles](data/circles_gh.png)](https://github.com/urschrei/Circles \"Borges's 'The Circular Ruins' is a good story. Also an apt title for my PhD.\")\n\n---\n### Installation and usage\n\n`pip install -r requirements.txt` or `uv pip install -r requirements.txt`. The use of a [virtualenv](http://virtualenv.readthedocs.org/en/latest/) is advised.  \nThe Rust libraries (though not their Python counterparts) require a Rust installation. For most platforms (macOS, Windows, *nix), using [rustup.rs](https://rustup.rs) is the easiest way to install and update a Rust installation.\n\n### License\n© Stephan Hügel 2017 - 2025 \n\nUnless otherwise specified, the [wards.geojson](wards.geojson) file and any UK shapefiles are provided under\n[Crown Copyright](http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/copyright/crown-copyright/), and their use must be acknowledged in any output by reproducing the following notice:\n\n`Contains Ordnance Survey data  \n© Crown copyright and database right 2015`\n\nUnless otherwise specified, all other files are provided under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International](http://creativecommons.org/licenses/by-nc-sa/4.0/) license.  \n\n![CC BY-NC-SA 4.0](https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furschrei%2Fgeopython","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furschrei%2Fgeopython","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furschrei%2Fgeopython/lists"}