street-view-randomizer


Namestreet-view-randomizer JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryGenerate random Google Street View images from all around the world
upload_time2022-12-04 04:26:39
maintainer
docs_urlNone
author
requires_python>=3.6
licenseMIT License Copyright (c) 2022 Diego Paiva Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords google street view api random images
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Street View Randomizer

![GitHub](https://img.shields.io/github/license/diegopaiva1/street-view-randomizer)
![GitHub repo size](https://img.shields.io/github/repo-size/diegopaiva1/street-view-randomizer)

A Python command-line interface designed to generate random images from [Google Street View](http://maps.google.com).

Generate random Google Street View images from all around the world.

## Requirements

- Python >= 3.6
- [Google Maps Platform](https://developers.google.com/maps) API key

## Install

```
pip install street-view-randomizer
```

## Usage

The basic usage defaults to generating a single image anywhere in the world (equal probabilities with respect to countries sizes):

```
street-view-randomizer --api-key=yourapikeyhere
```

The output will be something like:

```
Searched image in PRI | lon:   -65.99685876172165 lat:    18.08766139664086 | elapsed time:   399.14ms

> Image found in PRI (Puerto Rico) | lon: -66.0217481, lat: 18.1029857 | attempts: 1 | total elapsed time: 0.40s
	(1/1)	Saving to ./images/pri/-66.0217481_18.1029857_h0_p0_f90.jpg...
```

### API key

The script will fallback to the [Google Maps Platform](https://developers.google.com/maps) API key in the `GOOGLE_MAPS_API_KEY` environment variable if the `--api-key` argument is not provided. You can set it in your `.bashrc` or `.zshrc` file:

```
export GOOGLE_MAPS_API_KEY=yourapikeyhere
```

### General options

Here is a list of some useful flags one may pass to customize the behavior of the script.

#### `-k, --api-key`

[Google Maps Platform](https://developers.google.com/maps) API key.

#### `-c, --countries`

Use the `-c` argument together with a list of one or more [ISO3 country codes](https://www.iban.com/country-codes) to narrow the search. For instance, if we are interested in fetching an image from either Brazil, Argentina or Chile:

```
street-view-randomizer -c BRA ARG CHL
```

#### `-l, --list-countries`

Display a list of all available countries (those with some Google Street View Coverage).

#### `-r, --radius`

Defines a radius in meters centered on a latitude and longitude. The default value is 5.000 (5km). This value should only be increased if searching for an image is taking too long.

#### `-a, --use-area`

If the size of the country matters when sampling from a group of countries, passing in the `-a` flag will give bigger countries more chances of being drawn. The following chart shows the odds for each country if we consider the full space search:

![areas_percentage](https://user-images.githubusercontent.com/32985519/204120495-179ce98a-7544-4cd8-a22c-e10ccab81fed.png)

#### `-n, --samples`

To **sample** more than once (this doesn't mean fetching more than one image per country), pass in the `-n` flag with some desired number, e.g.:

```
street-view-randomizer -n 3
```

Note that the maximum number of iterations allowed is **28.000**, which happens to be the maximum number of requests per month one can make without being charged by the Google Maps Platform. Be careful!

#### `-o, --output-dir`

By default all images are saved under the `images` directory from where the script is executed. To change the output directory, pass in the `-o` flag with the desired path, e.g.:

```
street-view-randomizer -o /home/user/images
```

### Image options

Images will be saved to a directory named after the country code (ISO3) where the following naming convention applies:

```
<lon>_<lat>_h<heading>_p<pitch>_f<fov>.jpg
```

Please refer to the [Street View Static API documentation](https://developers.google.com/maps/documentation/streetview/request-streetview) to understand the meaning of `heading`, `pitch` and `fov`.

Anyway, you are allowed to pass a list of each one of these parameters to generate different imagery from the same coordinate.

#### `-H, --headings`

List of headings, e.g., `-H 0 90 180 270`. The default value is 0.

#### `-P, --pitches`

List of pitches, e.g., `-P -35 0 35`. The default value is 0.

#### `-F, --fovs`

List of fovs, e.g., `-F 60 90 120`. The default value is 90.

Note that the total number of images will be the product of the length of each list. For each heading, the algorithm will output an image for each pair of pitch and fov.

#### `-S, --size`

Size of the output image, defaults to 256x256. The maximum size allowed is 640x640. Each dimension must have at least a hundred pixels.

### Putting it all together

The following command will perform 3 weighted samplings of 12 images of size 512x512:

```
street-view-randomizer -n 3 -a -H 0 90 180 270 -P -45 0 35 -S '512x512'
```

## Contributing

The code should be pretty straightforward to understand and modify. Feel free to open an issue or submit a pull request.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "street-view-randomizer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "google,street view,api,random,images",
    "author": "",
    "author_email": "Diego Paiva <diego.paiva13@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/95/84/5bbd5e7ef149e0bc01cab293d8b27faef5645a1af4f539a0990832efc929/street-view-randomizer-0.1.0.tar.gz",
    "platform": null,
    "description": "# Street View Randomizer\n\n![GitHub](https://img.shields.io/github/license/diegopaiva1/street-view-randomizer)\n![GitHub repo size](https://img.shields.io/github/repo-size/diegopaiva1/street-view-randomizer)\n\nA Python command-line interface designed to generate random images from [Google Street View](http://maps.google.com).\n\nGenerate random Google Street View images from all around the world.\n\n## Requirements\n\n- Python >= 3.6\n- [Google Maps Platform](https://developers.google.com/maps) API key\n\n## Install\n\n```\npip install street-view-randomizer\n```\n\n## Usage\n\nThe basic usage defaults to generating a single image anywhere in the world (equal probabilities with respect to countries sizes):\n\n```\nstreet-view-randomizer --api-key=yourapikeyhere\n```\n\nThe output will be something like:\n\n```\nSearched image in PRI | lon:   -65.99685876172165 lat:    18.08766139664086 | elapsed time:   399.14ms\n\n> Image found in PRI (Puerto Rico) | lon: -66.0217481, lat: 18.1029857 | attempts: 1 | total elapsed time: 0.40s\n\t(1/1)\tSaving to ./images/pri/-66.0217481_18.1029857_h0_p0_f90.jpg...\n```\n\n### API key\n\nThe script will fallback to the [Google Maps Platform](https://developers.google.com/maps) API key in the `GOOGLE_MAPS_API_KEY` environment variable if the `--api-key` argument is not provided. You can set it in your `.bashrc` or `.zshrc` file:\n\n```\nexport GOOGLE_MAPS_API_KEY=yourapikeyhere\n```\n\n### General options\n\nHere is a list of some useful flags one may pass to customize the behavior of the script.\n\n#### `-k, --api-key`\n\n[Google Maps Platform](https://developers.google.com/maps) API key.\n\n#### `-c, --countries`\n\nUse the `-c` argument together with a list of one or more [ISO3 country codes](https://www.iban.com/country-codes) to narrow the search. For instance, if we are interested in fetching an image from either Brazil, Argentina or Chile:\n\n```\nstreet-view-randomizer -c BRA ARG CHL\n```\n\n#### `-l, --list-countries`\n\nDisplay a list of all available countries (those with some Google Street View Coverage).\n\n#### `-r, --radius`\n\nDefines a radius in meters centered on a latitude and longitude. The default value is 5.000 (5km). This value should only be increased if searching for an image is taking too long.\n\n#### `-a, --use-area`\n\nIf the size of the country matters when sampling from a group of countries, passing in the `-a` flag will give bigger countries more chances of being drawn. The following chart shows the odds for each country if we consider the full space search:\n\n![areas_percentage](https://user-images.githubusercontent.com/32985519/204120495-179ce98a-7544-4cd8-a22c-e10ccab81fed.png)\n\n#### `-n, --samples`\n\nTo **sample** more than once (this doesn't mean fetching more than one image per country), pass in the `-n` flag with some desired number, e.g.:\n\n```\nstreet-view-randomizer -n 3\n```\n\nNote that the maximum number of iterations allowed is **28.000**, which happens to be the maximum number of requests per month one can make without being charged by the Google Maps Platform. Be careful!\n\n#### `-o, --output-dir`\n\nBy default all images are saved under the `images` directory from where the script is executed. To change the output directory, pass in the `-o` flag with the desired path, e.g.:\n\n```\nstreet-view-randomizer -o /home/user/images\n```\n\n### Image options\n\nImages will be saved to a directory named after the country code (ISO3) where the following naming convention applies:\n\n```\n<lon>_<lat>_h<heading>_p<pitch>_f<fov>.jpg\n```\n\nPlease refer to the [Street View Static API documentation](https://developers.google.com/maps/documentation/streetview/request-streetview) to understand the meaning of `heading`, `pitch` and `fov`.\n\nAnyway, you are allowed to pass a list of each one of these parameters to generate different imagery from the same coordinate.\n\n#### `-H, --headings`\n\nList of headings, e.g., `-H 0 90 180 270`. The default value is 0.\n\n#### `-P, --pitches`\n\nList of pitches, e.g., `-P -35 0 35`. The default value is 0.\n\n#### `-F, --fovs`\n\nList of fovs, e.g., `-F 60 90 120`. The default value is 90.\n\nNote that the total number of images will be the product of the length of each list. For each heading, the algorithm will output an image for each pair of pitch and fov.\n\n#### `-S, --size`\n\nSize of the output image, defaults to 256x256. The maximum size allowed is 640x640. Each dimension must have at least a hundred pixels.\n\n### Putting it all together\n\nThe following command will perform 3 weighted samplings of 12 images of size 512x512:\n\n```\nstreet-view-randomizer -n 3 -a -H 0 90 180 270 -P -45 0 35 -S '512x512'\n```\n\n## Contributing\n\nThe code should be pretty straightforward to understand and modify. Feel free to open an issue or submit a pull request.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Diego Paiva  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Generate random Google Street View images from all around the world",
    "version": "0.1.0",
    "split_keywords": [
        "google",
        "street view",
        "api",
        "random",
        "images"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "43485cf4e9a2978dbb9d1469f0a7adab",
                "sha256": "b79ad6abd62ac364f0c830543182876a1592dc7d41ac6b4e9b373e45eab6aeed"
            },
            "downloads": -1,
            "filename": "street_view_randomizer-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "43485cf4e9a2978dbb9d1469f0a7adab",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10978,
            "upload_time": "2022-12-04T04:26:36",
            "upload_time_iso_8601": "2022-12-04T04:26:36.709331Z",
            "url": "https://files.pythonhosted.org/packages/fa/0a/426be531bfeb75994c53e00229c484fb8185350d034670b3a679fbc14fdd/street_view_randomizer-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "197f94df2f3594e067b4f319c9862b93",
                "sha256": "fcb9f11236e76b9b60625ea52746c9b1b0dd8d702ee1ed26bcd039d41bf177c8"
            },
            "downloads": -1,
            "filename": "street-view-randomizer-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "197f94df2f3594e067b4f319c9862b93",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3547569,
            "upload_time": "2022-12-04T04:26:39",
            "upload_time_iso_8601": "2022-12-04T04:26:39.760729Z",
            "url": "https://files.pythonhosted.org/packages/95/84/5bbd5e7ef149e0bc01cab293d8b27faef5645a1af4f539a0990832efc929/street-view-randomizer-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-04 04:26:39",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "street-view-randomizer"
}
        
Elapsed time: 0.01604s