Skip to content

init command

Casper van Battum edited this page Nov 18, 2023 · 4 revisions

Usage

Create and initialize a new project. A project has a name, stores an area (defined by the coordinates and the zoom level), and has several custom settings.

> mapsnap init <name> <coordA> <coordB> <zoom> [--file-type png|jpg] [--name-format date|index]

Aliases

init, i create, c

Arguments

These arguments are required.

name:

The name of the project. The project will be saved in a subfolder with the project's name. The folder will contain the config file mapsnap.json, which also stores the name.

coordA/coordB:

Two coordinate pairs indicating the bounds of the area to snapshot. A and B can be in any order, as long as they are two corner points of the bounding box. The coordinates should be in decimal form, and separated by a space, comma, forward slash or semicolon:

  • 51.507222, -0.1275
  • -33.4392;-70.6478
  • 50 -100
  • 45.52450/-65.82191 (this can directly be copied from the url on the openstreetmap.org map viewer)

See also: Where do I find my coordinates and zoom level?

zoom:

The zoom level of the map. Should be an integer number between 0 and 19, as defined by OpenStreetMap.

See also: Where do I find my coordinates and zoom level?

Options

These options are optional and have default values

--file-type, -t:

Sets the file type for the output files. The default is png.

Values: png, jpg

--name-format,-n,-f

Defines the way in which the output files will be named. The default format is date. Date naming follows the year/month/day naming format, making the files easy to sort. Index naming always takes into account earlier files with the same project name. Warning: index naming will find the first index that isn't used. If your project folder contains file1, file2 and file4, then your next image will be called file3.

-date naming: myProject 2021-01-31 18_36_54.png ([project name] [year]-[month]-[date] [hour]_[minutes]_[seconds].png)

-index naming: myProject34.png ([project name][index].png)

--pixel-perfect, -P

Crops the image to the exact pixel of where the coordinate is located. When turned off, the entire tile in which the coordinate falls is downloaded. This causes non-pixel-perfect snaps to always have sizes that are multiples of 256. Off by default.

Edge cases

During project creation, you may be prompted with a few question.

  • If the combination of coordinates and zoom level results in an image larger than 100MP, you will be asked if you want to continue. These large images often have a large file size (hundreds of megabytes), very slow download times (especially on slow connections) and high RAM requirements. It is recommended to choose a smaller area if you don't have a beefy computer and fast internet.
  • When you try to create a project with a name that already exists, you can get several different prompts for confirmation. The program will try to detect if the target folder is emtpy, and whether it contains a mapsnap project already. Any existing project file (mapsnap.json) will be overwritten when you confirm the creation of a project!. All other files (including downloaded images) will remain in the folder.

Clone this wiki locally