Uploader tools for KartaView

kartaview, updated 🕥 2022-12-17 23:29:35


KartaView Tools


Tools developed by KartaView to help contributors.

  • Python 3.6+
  • Dependencies from requirements.txt file. The dependencies can be installed by running: ``` pip3 install virtualenv

virtualenv -p python3 .

source bin/activate

pip3 install -r requirements.txt ```

1. Upload photos to KartaView


This script is used to upload sequences from a local directory. The available formats are: * Sequences taken with the OSC mobile apps * Exif images


``` cd /path_to_scripts/osc_tools


python osc_tools.py -h

help for upload

python osc_tools.py upload -h

upload all sequences from ~/OSC_sequences folder

python osc_tools.py upload -p ~/OSC_seqences


2. Generate Exif info


This script generates GPS Exif for each image. It has two options generating exif info from metadata file or generating exif info from a custom geojson file.

``` cd /path_to_scripts


python osc_tools.py -h

help for Exif generation

python osc_tools.py generate_exif -h ```

Option I. From an KV metadata format file


Exif generation for mobile recorded sequence having metadata files in ~/OSC_sequences/Sequence1 folder

python osc_tools.py generate_exif -exif_source metadata -p ~/OSC_seqences/Sequence1


Option II. From custom geojson file and the images that require the exif data


Exif generation for custom geojson + imagery

python osc_tools.py generate_exif -exif_source custom_geojson -p ~/CustomFolderContainingGeoJsonAndImages


Folder structure ~/CustomFolderContainingGeoJsonAndImages
~/CustomFolderContainingGeoJsonAndImages/folder_with_images/image1.jpg ~/CustomFolderContainingGeoJsonAndImages/folder_with_images/image2.jpg ~/CustomFolderContainingGeoJsonAndImages/folder_with_images/image3.jpg
Expand to see the custom geojson sample: ```javascript { "type":"FeatureCollection", "features":[ { "type":"Feature", "properties":{ "order":1.0, "path":"folder_with_images/image1.jpg", "direction":236.0, "Lat":1.910309, "Lon":1.503069, "Timestamp":"2020-01-20T08:00:01Z" }, "geometry":{ "type":"Point", "coordinates":[ 1.503069408072847, 1.910308570011793 ] } }, { "type":"Feature", "properties":{ "order":2.0, "path":"folder_with_images/image2.jpg", "direction":236.0, "Lat":1.910199, "Lon":1.502908, "Timestamp":"2020-01-20T08:01:21Z" }, "geometry":{ "type":"Point", "coordinates":[ 1.502907515952158, 1.910198963742701 ] } }, { "type":"Feature", "properties":{ "order":3.0, "path":"folder_with_images/image3.jpg", "direction":236.0, "Lat":1.910096, "Lon":1.502764, "Timestamp":"2020-01-20T08:12:10Z" }, "geometry":{ "type":"Point", "coordinates":[ 1.50276400212099, 1.910095961756973 ] } } ] } ```

Docker Support

To run the scripts inside a Docker container: make docker docker run -Pit osc-up osc_tools.py docker run -Pit --mount type=bind,source="$(pwd)",target=/opt/osc osc-up /opt/osc/osc_tools.py The 'images' directory in the repo will be available in the container at /opt/osc/images


virtualenv error

opened on 2022-12-30 16:55:55 by hermann-san

Hi, I've tried to install the dependencies for the Script but I get an error message when I run the second line: pip3 install virtualenv virtualenv -p python3 . source bin/activate pip3 install -r requirements.txt After I've run pip3 install virtualenv I get these warnings

WARNING: The script virtualenv is installed in '/home/hermann/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

I run virtualenv -p python3 . It says, virtualenv not found but can be installed with sudo apt install python3-virtualenv I've installed it and run virtualenv -p python3 . Then came an error message: AttributeError: module 'virtualenv.create.via_global_ref.builtin.cpython.mac_os' has no attribute 'CPython2macOsArmFramework'

From some internet reseach someone suggested pip3 uninstall virtualenv sudo pip3 uninstall virtualenv sudo apt purge python3-virtualenv sudo pip3 install virtualenv

That didn't help, so I started over again with sudo pip3 uninstall virtualenv sudo apt purge python3-virtualenv pip3 install virtualenv virtualenv -p python3 . Then an error came with File or directory not found

I did export PYTHONPATH="/home/hermann/.local/bin" but it didn't help. It still says File or directory not found

do you have any sugggestions what else I could do to get this running?

I'm on Linux Mint 20.1 with Python 3.8.10 Thanks for your help.

Fixed JSONDecodeError #134

opened on 2022-12-17 23:29:35 by kudarisenmon

Fixed: JSONDecodeError occurs when Image Description tag is not in JSON format #134

JSONDecodeError occurs when Image Description tag is not in JSON format

opened on 2022-12-17 22:42:11 by kudarisenmon

When I uploaded photos that did not have an Image Description tag in JSON format, I got a json.decoder.JSONDecodeError as shown in the traceback below. Traceback (most recent call last): File "./osc_tools.py", line 243, in <module> main() File "./osc_tools.py", line 24, in main args.func(args) File "./osc_tools.py", line 95, in upload_command sequences = discoverer.discover(path) File "/home/pi/src/upload-scripts/osc_discoverer.py", line 113, in discover sequences = sequences + self.discover(full_path) File "/home/pi/src/upload-scripts/osc_discoverer.py", line 114, in discover sequence = self.create_sequence(path) File "/home/pi/src/upload-scripts/osc_discoverer.py", line 129, in create_sequence (visual_data, data_type) = self.visual_data.discover(path) File "/home/pi/src/upload-scripts/visual_data_discover.py", line 50, in discover photo = cls._photo_from_path(os.path.join(path, file_path)) File "/home/pi/src/upload-scripts/visual_data_discover.py", line 130, in _photo_from_path exif_parser.next_item_with_class(PhotoMetadata)) File "/home/pi/src/upload-scripts/parsers/exif/exif.py", line 47, in next_item_with_class return self._photo_item(self.tags) File "/home/pi/src/upload-scripts/parsers/exif/exif.py", line 171, in _photo_item gps = self._gps_item(tags_data) File "/home/pi/src/upload-scripts/parsers/exif/exif.py", line 133, in _gps_item gps.timestamp = self._gps_timestamp(tags_data) File "/home/pi/src/upload-scripts/parsers/custom_data_parsers/custom_mapillary.py", line 21, in _gps_timestamp description = json.loads(description) File "/usr/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Prettify and augment README.md

opened on 2022-11-07 11:58:53 by JakeSmarter

Just so that users know. :wink:

Feel free to cherry pick this PR.

credentials.json into XDG config space not current directory

opened on 2022-08-14 15:33:14 by flohoff

Hi, the credentials.json should not be in the current directory but in the normal XDG namespace somethink like ~/.config/karta/credentials.json

Currently i need to login on every upload because i change into the directory of the images and upload "."


360 Panoramic Viewer on OpenStreetMap iD Editor

opened on 2021-11-17 10:51:56 by valeriodeluca

Thanks to the updates of @salabogdan I can upload 360 photos to KV very well by Python, creating EXIFs from custom geojson:

Sample KV metadata file to generate of Exif info #117 https://github.com/kartaview/upload-scripts/issues/117

In KV I can dynamically and interactively see each 360 photo of the sequence: https://kartaview.org/details/3936361/0/track-info

I can also see the sequence in OpenStreetMap's iD Editor, but in the photo viewer I only see the plan photo mode: https://github.com/openstreetmap/iD

360 photos on OpenStreetMap iD Editor: 360_Panoramic_Viewer_in_OpenStreetMap_iD_Editor https://www.openstreetmap.org/edit?editor=id#map=19/41.91031/12.50307

Wonder if there is a way to view the KartaView viewer in interactive 360 degree panoramic mode with the angle pointer dynamically moving with the 360 photo in OpenStreetMap iD Editor, very usefull for mapping in OSM with own 360 photos.

I have seen that some Mapillary 360 photo sequences are displayed interactively on the OpenStreetMap iD Editor.

Thanks a lot


KartaView - the crowdsourced, free and open street level imagery platform for OpenStreetMap

GitHub Repository