https://github.com/dkogan/osmgnuplot
Script to make it easy to plot OSM tiles in gnuplot
https://github.com/dkogan/osmgnuplot
Last synced: about 1 year ago
JSON representation
Script to make it easy to plot OSM tiles in gnuplot
- Host: GitHub
- URL: https://github.com/dkogan/osmgnuplot
- Owner: dkogan
- License: other
- Created: 2015-08-16T04:51:59.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-03-31T22:28:01.000Z (about 1 year ago)
- Last Synced: 2025-03-31T23:27:09.883Z (about 1 year ago)
- Language: Perl
- Size: 25.4 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- License: LICENSE
Awesome Lists containing this project
README
=head1 NAME
osmgnuplot.pl - Download OSM tiles, and make a gnuplot script to render them
=head1 SYNOPSIS
$ osmgnuplot.pl --center 34.094719,-118.235779 --rad 300m --zoom 16
Downloading http://tile.openstreetmap.org/16/11243/26158.png
Downloading http://tile.openstreetmap.org/16/11244/26158.png
Downloading http://tile.openstreetmap.org/16/11243/26159.png
Downloading http://tile.openstreetmap.org/16/11244/26159.png
Done! Gnuplot script 'montage_34.094719_-118.235779_300m_16.gp' uses the image 'montage_34.094719_-118.235779_300m_16.png'
$ gnuplot -persist montage_34.094719_-118.235779_300m_16.gp
[a gnuplot window pops up, showing OSM tiles]
=head1 DESCRIPTION
This script downloads OSM tiles, glues them together into a single image, and
generates a gnuplot script to render this image, aligned correctly to its
latitude, longitude (on the gnuplot y2 and x2 axes respectively). While this in
itself is not useful, the gnuplot script can be expanded to plot other things on
top of the map, to make it easy to visualize geospatial data. Example plots
appear here:
L
The generated gnuplot script darkens the map a bit to make the extra stuff stand
out (C parameter in the resulting script).
The communication with the OSM tile server assumes some caching. If an
appropriately-named tile already exists on disk, the C header
field is used to send over the MD5 hash of the tile on disk. If the tile on the
server has the same hash, the server doesn't bother sending it over, which
results in bandwidth savings.
The OSM tiles have a nonlinear relationship between longitude and tile pixels.
The gnuplot script generated here applies the nonlinearity to the y2 axis, so
the plotted image is not distorted, but the axes are still showing the correct
data. A side-effect of this is that latitude is on the y2 axis and longitude is
on the x2 axis. For instance, to plot a file C containing
latitude,longitude columns with points on top of the stitched OSM tiles, do this:
plot "montage_....png" ...., \
"latlon.dat" using 2:1 with points axis x2y2
The C<"montage..."> stuff is generated by C, and the user would
add the C<"latlon.dat"> stuff.
Note that some versions of gnuplot have a minor bug, and you may see the following message:
warning: could not confirm linked axis inverse mapping function
This is benign, and can be ignored
=head1 REQUIRED ARGUMENTS
=over
=item --center ,
Center point
=for Euclid:
lat.type: number
lon.type: number
=item --rad
How far around the center to query. This must include units (support C, C
and C; no whitespace between the number and units).
=for Euclid:
radius.type: /[0-9]+(?:\.[-9]*)?(?:miles?|km|m)/
=item --zoom
The OSM zoom level
=for Euclid:
zoom.type: integer, zoom > 0 && zoom <= 18
=for Euclid:
radius.type: /[0-9]+(?:\.[-9]*)?(?:miles?|km|m)/
=back
=head1 OPTIONAL ARGUMENTS
=over
=item --serverpath
The base URL to grab tiles from. We default to the OSM tile server:
C
=for Euclid:
url.type: string
url.default: "http://tile.openstreetmap.org"
=back
=head1 DEPENDENCIES
I use non-core perl modules C and C. I also use
the C tool from C. On a Debian box the following should be
sufficient:
apt-get install libgetopt-euclid-perl libwww-perl imagemagick
=head1 REPOSITORY
L
=head1 AUTHOR
Dima Kogan, C<< >>
=head1 LICENSE AND COPYRIGHT
Copyright 2015 Dima Kogan.
This program is free software; you can redistribute it and/or modify it under
the terms of the Lesser General Public License version 3, as published by the
Free Software Foundation. Full text at http://www.gnu.org/licenses/lgpl.html