circles

Draw geodesic circles exhibiting projection distortion using Basemap

https://github.com/urschrei/circles

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
Last synced: 10 months ago · JSON representation

Repository

Draw geodesic circles exhibiting projection distortion using Basemap

Basic Info
  • Host: GitHub
  • Owner: urschrei
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 3.67 MB
Statistics
  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • Open Issues: 2
  • Releases: 0
Created about 12 years ago · Last pushed over 11 years ago
Metadata Files
Readme License

README.md

Circles

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:

DOI

Owner

  • Name: Stephan Hügel
  • Login: urschrei
  • Kind: user
  • Location: Dublin
  • Company: Trinity College Dublin

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

All Time
  • Total Commits: 27
  • Total Committers: 2
  • Avg Commits per committer: 13.5
  • Development Distribution Score (DDS): 0.222
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 2
  • Downloads: 16 Last month
Rankings
Dependent packages count: 10.0%
Dependent repos count: 11.6%
Average: 18.5%
Stargazers count: 21.5%
Forks count: 22.6%
Downloads: 26.9%
Maintainers (1)
Last synced: 11 months ago

Dependencies

setup.py pypi
  • numpy *