The application OSM-Psychology
provides a simple tool to generate CSV and JSON files about the OpenStreetMap data (map snapshot and history) that can be used for psychological research.
To prepare for running the software, some preparations need to be made:
- Download and install the current Java Development Kit.
- Download and install IntelliJ IDEA IDE.
- During the installation settings, tick the checkbox for .java to be associated with IntelliJ.
- When running IntelliJ the first time, a message might appear in the lower right corner. Click "Skip All and Set Default".
- Download a OpenStreetMap database from ohsome Data Repository and save it to a directory of your choice. Due to file size, it is recommended to download a file that covers your area of interest.
Then, you can start setting up your project.
- Download the file myOSMPsychology.zip and extract it to a directory of your choice. This will be the location where the files are exported and saved to.
- Start IntelliJ, click "Open", and navigate to the directory where you previously exported the program files.
- Follow the path structure on the right
/src/main/java/com.osm.myPsychology
and edit the fileMain
.- Open the file by clicking it.
- Adapt the content of this file by replacing
/path/to/database/baden-wuerttemberg.oshdb.mv.db
by the path of the database you downloaded in Step 3. - Adapt the commands for extracting the data according to your needs.
- Run the file
Main
by clickingrun
in its context menu (right click).
Below, you will find several examples and further documentation.
To identify the coordinates for a bounding box – this is needed to specify an area of interest – you can use the the BoundingBox tool or export the coordinates from OpenStreetMap.
Get entities in the data (i.e., in Heidelberg) at 2019-01-01 and export those with all available information to CSV.
Data.load("/path/to/your/OSMdata/heidelberg.oshdb.mv.db");
ExportEntities.csv(new StrategyAll(), "2019-01-01", Col.ALL);
Get all changes made to roads in Heidelberg in 2008 and export those with basic information to a CSV-formatted file.
Data.load("/path/to/your/OSMdata/Heidelberg.oshdb.mv.db");
ExportContributions.csv(new StrategyRoads(), "2008-01-01", "2008-12-31", Col.BASIC_INFORMATION);
Get all changes made to nodes in Eppelheim, a town near Heidelberg, and export them with basic information and tag information to a JSON-formatted file.
Data.load("/path/to/your/OSMdata/Heidelberg.oshdb.mv.db");
BoundingBox eppelheim = new BoundingBox("Eppelheim", 8.6159, 49.3868, 8.6555, 49.4153);
ExportContributions.json(new StrategyNodes(), eppelheim, "2008-01-01", "2008-12-31", Col.BASIC_INFORMATION, Col.TAG_INFORMATION);
A R script to read the JSON file into R is provided here.
Further documentation for the functions can be found on these pages.
- Data.load - Setting the path to the OSHDB file
- BoundingBox - Setting a bounding box
- ExportEntities.csv - Exporting snapshot data in a CSV file
- ExportContributions.csv - Exporting contribution data in a CSV file
- ExportEntities.json - Exporting snapshot data in a JSON file
- ExportContributions.json - Exporting contribution data in a JSON file
- tba
This application is written and maintained by Franz-Benjamin Mocnik mail@mocnik-science.net, Maren Mayer maren.mayer@students.uni-mannheim.de, and Daniel W Heck heck@uni-mannheim.de.
For questions, please approach Maren Mayer maren.mayer@students.uni-mannheim.de.
(c) by Franz-Benjamin Mocnik, Maren Mayer, and Daniel W Heck, 2019–2021.
The code is licensed under the MIT license.