circles
Draw geodesic circles exhibiting projection distortion using Basemap
Science Score: 33.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.1%) to scientific vocabulary
Repository
Draw geodesic circles exhibiting projection distortion using Basemap
Basic Info
Statistics
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 2
- Releases: 0
Metadata Files
README.md
Circles
A map projection is a systematic transformation of the latitudes and longitudes of locations on the surface of a sphere or an ellipsoid into locations on a plane.
— (Snyder, J. P., 1989)
Simply drawing a circle on that plane using cartesian coordinates will result in something that is…wrong.
Thomas Lecoq has helpfully translated some JS code written by Ed Williams into Python, in order to allow the correct calculation of great-circle distances for the WGS84 ellipsoid. I've reproduced it here with some minor alterations, in the form of Circles, a small convenience library. It's designed to be used with the Basemap extension to matplotlib, and it requires the Numpy library. Install it using pip: pip install circles
Circles exposes a single method, circle(). Pass it your Basemap instance, longitude and latitude of the point you'd like as the centre of your circle, and the radius. It will return a list of lon, lat tuples in map projection coordinates, which can be passed to your Basemap instance for plotting, or converted into Polygons using Shapely, and then plotted using Descartes.
A simple example:
```Python
the shaded circle has the wrong shape
from Circles.circles import circle from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt from shapely.geometry import Polygon, Point from descartes import PolygonPatch import numpy as np
use the Robinson projection - it'll distort nicely
m = Basemap(resolution='l', projection='robin', lon_0=0)
radius = 2000 centerlon = 0.135875 centerlat = 51.5219198
initialise a point and construct a buffered polygon
p = Point(m(centerlon, centerlat)) buffered = p.buffer(radius * 1000)
same radius, but with calculated coordinates
casa = circle(m, centerlon, centerlat, radius) pol = Polygon(casa)
initialise a new plot and axes
plt.clf() fig = plt.figure() ax = fig.addsubplot(111, axisbg='w', frameon=False)
draw map features
m.drawmapboundary(fillcolor='#dfedff', linewidth=0.25, zorder=0, ax=ax) m.drawcountries(linewidth=.25, color='#000000', zorder=2, ax=ax) m.drawcoastlines(linewidth=1., zorder=1, ax=ax) m.fillcontinents(color='#555555', lakecolor='#C4C4C4',zorder=1, ax=ax) m.drawparallels(np.arange(-90., 120., 30.), alpha=0.5, lw=0.25, zorder=1, ax=ax) m.drawmeridians(np.arange(0., 360., 60.), alpha=0.5, lw=0.25, zorder=1, ax=ax)
draw circles
incorrect = PolygonPatch(buffered, fc='none', ec='#333333', lw=0, ls='dotted', hatch='....', zorder=1) correct = PolygonPatch(pol, fc='#00BABA', ec='#ffffff', alpha=.5, zorder=3) ax.addpatch(incorrect) ax.addpatch(correct)
with apologies to the Sugababes
plt.title("Round round baby, round round") plt.tightlayout() fig.setsize_inches(12., 8.) plt.show() ```
The shaded circle centred on Ritoque is drawn using cartesian coordinates, while the fuchsia, blue and transparent circles – the latter two centred on London and Perth, respectively – have been drawn using Circles. As can be seen, these are correctly distorted, in line with the parallels and meridians drawn on the Robinson projection, which distorts moderately at the latitudes in question.
The IPython Notebook used to generate the graphic can be viewed here.
TODO
- [ ] Wrapping the circle correctly across map bounds is a very tricky problem. I gather Leaflet does this well as of 0.8
Citation
This work may be cited using the following DOI:
Owner
- Name: Stephan Hügel
- Login: urschrei
- Kind: user
- Location: Dublin
- Company: Trinity College Dublin
- Website: https://scholar.google.com/citations?hl=en&user=usNnd3IAAAAJ&view_op=list_works&sortby=pubdate
- Twitter: urschrei
- Repositories: 55
- Profile: https://github.com/urschrei
Marie Curie research fellow at TCD: smart cities and climate change. Prev: @casa-ucl. I also work on high-performance computational geometry libraries @georust
GitHub Events
Total
- Issues event: 1
Last Year
- Issues event: 1
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Stephan Hügel | u****i@g****m | 21 |
| Stephan Hügel | s****2@u****k | 6 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 2
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 2
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- urschrei (1)
- ejtasker (1)
- prakashvedagiri (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 16 last-month
- Total dependent packages: 0
- Total dependent repositories: 2
- Total versions: 1
- Total maintainers: 1
pypi.org: circles
Draw correctly-projected circles on a Basemap plot
- Homepage: https://github.com/urschrei/circles
- Documentation: https://circles.readthedocs.io/
- License: MIT
-
Latest release: 0.1
published about 12 years ago
Rankings
Maintainers (1)
Dependencies
- numpy *

