Skip to main content

A highly opinionated way to paint and plot black and white map

Project description

MonochroMap

A compact library to paint and plot black and white map. Inspired and continued from StaticMap.

Some of the modifications are:

  • changed default tile to stamen toner
  • streamlined graphical component addition with only same function
  • supported graphical component alpha/transparency blending
  • fixed many iconmarker IO error in one image

Example

Draw Lines

This example code will show the location of Laugh Tale from intersection of coordinates given by 4 road poneglyphs.

from monochromap import MonochroMap, Line

m = MonochroMap()
line = Line(((13.4, 52.5), (2.3, 48.9)), '#ff000088', 15)
m.add_feature(line)

line = Line(((4.9041, 52.3676), (7.27, 46.57)), '#0000ff88', 15)
m.add_feature(line)

m.render()

Europe

Draw Points

This example code will show the hotspot of California forest fire. Don't ask why there is fire in the ocean, it's global warming.

from monochromap import MonochroMap, Point

m = MonochroMap()
for i in range(1000):

    lat = 36.7783 + rng.normal()
    lon = -119.4179 + rng.normal()

    p = Point((lon, lat), '#fb294344', 5)
    m.add_feature(p)

m.render()

California

Draw (any) Polygon

This example will show how to plot one instance of polygon, namely rectangle. Other shape of polygon is left as an exercise for the reader.

from monochromap import MonochroMap, Polygon

m = MonochroMap()

lon0, lat0 = (-6.114878, 106.731217)
lon1, lat1 = (-6.311491, 106.951200)
points = [[lat0, lon0], [lat0, lon1], [lat1, lon1], [lat1, lon0]]
m.add_feature(Polygon(points, '#ff000022', 'black'))

lon0, lat0 = (-6.156652, 106.912689)
lon1, lat1 = (-6.319975, 107.027262)
points = [[lat0, lon0], [lat0, lon1], [lat1, lon1], [lat1, lon0]]
m.add_feature(Polygon(points, '#00ff0033', 'black'))

lon0, lat0 = (-6.225684, 106.637555)
lon1, lat1 = (-6.319054, 106.807583)
points = [[lat0, lon0], [lat0, lon1], [lat1, lon1], [lat1, lon0]]
m.add_feature(Polygon(points, '#0000ff44', 'black'))

m.render()

Jakarta

Draw Icon (random image)

You can also plot any random image into the map. Here we will show the total number of covid patient on the world most adept country at defeating pandemic, according to reputable source, Plague inc.

from monochromap import MonochroMap, IconMarker

m = MonochroMap()
lat, lon = (75.939847, -42.161182)

for i in range(78):

    icon = IconMarker(np.array([lon, lat]) + np.random.uniform(-0.3, 6.7, 2), '../samples/covid.png', 0, 0)
    m.add_feature(icon)

icon = IconMarker(np.array([-17.456606, 63.992837]) + np.random.uniform(-0.1, 0.1, 2), '../samples/covid.png', 0, 0)
m.add_feature(icon)

m.render()

Greenland

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monochromap-0.2.2.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

monochromap-0.2.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file monochromap-0.2.2.tar.gz.

File metadata

  • Download URL: monochromap-0.2.2.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for monochromap-0.2.2.tar.gz
Algorithm Hash digest
SHA256 043f6a28f329010866eef3fcce6669bdb3494163e65a1b4606fbc56c56d36780
MD5 9f2e083b000fdc332a736ec85910a18e
BLAKE2b-256 a2e07d7835fea1f6474b44b05a2d71fee1c59002dec173b3e2fed7198c1532f3

See more details on using hashes here.

File details

Details for the file monochromap-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: monochromap-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for monochromap-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64ce87ce2c718c7232909e2f9d2ec4377bc55a2c00f2a859f482b9f70a5eae0a
MD5 a11d36c81e7430235febb274abd4e591
BLAKE2b-256 c125ca4b81148d3b8a5456372c71ed497e8bbe35702a93c0bac69a2db1236cb9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page