Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Using OSM2CITY on Windows"

From FlightGear wiki
Jump to: navigation, search
(Guide on windows)
 
m (Fix osm2city parameters url)
 
(2 intermediate revisions by 2 users not shown)
Line 72: Line 72:
 
Under that folder I also created a "projects" folder.
 
Under that folder I also created a "projects" folder.
  
Next, I installed osmosis from [https://wiki.openstreetmap.org/wiki/Osmosis/Quick_Install_(Windows] and installed in osm2city-work.
+
Next, I installed osmosis from [https://wiki.openstreetmap.org/wiki/Osmosis/Quick_Install_(Windows)] and installed in osm2city-work.
  
  
Line 118: Line 118:
  
 
== Running osm2city ==
 
== Running osm2city ==
Next I create the params.ini file. For my purposes it is this - modify it according to docs at https://osm2city.readthedocs.io/en/late ... eters.html
+
Next I create the params.ini file. For my purposes it is this - modify it according to docs at https://osm2city.readthedocs.io/en/latest/parameters.html
  
 
I ended up with:
 
I ended up with:
Line 187: Line 187:
 
== Result ==
 
== Result ==
 
[[File:HYyyNb1.png]]
 
[[File:HYyyNb1.png]]
 +
 +
[[Category:OSM2City]]

Latest revision as of 14:34, 22 May 2019

This is a guide for Windows use of osm2city:

Preparation

Database

First, I downloaded Enterprise DB's version of PostgreSQL from: https://www.enterprisedb.com/downloads/postgres-postgresql-downloads I tested version 9.6 for Windows 64.

I will use the 'super-user' "postgres" and port 5432.

After installation, I launched the Stack Builder app included and I then installed PostGIS 2.5 under Spatial Extensions: TlvSqd4.png

After installation was finished, I then got PGAdmin 4 from https://www.pgadmin.org/download/ - this helps for managing databases (although I use commandline for most operations).

Python

Next, using Python 3.7 I installed these:

  • descartes
  • matplotlib
  • networkx
  • numpy (on Windows you need Numpy+MKL)
  • pil (Pillow)
  • pyproj
  • requests
  • scipy
  • shapely
  • psycopg2-binary

My pip freeze output: C:\Users\redpa> pip freeze

  • certifi==2018.11.29
  • chardet==3.0.4
  • cycler==0.10.0
  • Cython==0.28.5
  • decorator==4.3.0
  • descartes==1.1.0
  • ez-setup==0.9
  • idna==2.8
  • kiwisolver==1.0.1
  • matplotlib==3.0.1
  • networkx==2.2
  • numpy==1.14.6+mkl
  • Pillow==5.3.0
  • psycopg2==2.7.6
  • psycopg2-binary==2.7.6
  • pyparsing==2.3.0
  • pyproj==1.9.5.1
  • PyQt5==5.10.1
  • pyshp==1.2.12
  • python-dateutil==2.7.5
  • requests==2.21.0
  • scipy==1.1.0
  • Shapely==1.6.4.post1
  • sip==4.19.8
  • six==1.11.0
  • urllib3==1.24.1

Though, maybe not all of these are needed, some may be for other things; regardless that is all the modules installed on my system. Some packages did not work properly with pip; I got those from http://www.lfd.uci.edu/~gohlke/pythonlibs/, installing using the "wheel" file

Environment Variables

Then, in Environment Variables (search for Edit System Environment Variables on Windows 10 and hit on the bottom right "Environment Variables") I made sure PostgreSQL was in my PATH, which it was:

DUYP3c1.png

Then added FG_ROOT manually:

OOnYuie.png


Installing OSM2City tools

Next, I installed osm2city and osm2city-data from https://gitlab.com/fg-radi/osm2city-data and https://gitlab.com/fg-radi/osm2city. Both were installed in a new folder Documents/FlightGear/osm2city-work.

Under that folder I also created a "projects" folder.

Next, I installed osmosis from [1] and installed in osm2city-work.


Creating and Loading Database

Then, opening a CMD window, I created a database: this time I will make OSM scenery for Jan Mayen (a convenient tiny area).

createdb --encoding=UTF8 --owner=postgres --username=postgres janmayen

psql --username=postgres --dbname=janmayen -c "CREATE EXTENSION postgis;"

psql --username=postgres --dbname=janmayen -c "CREATE EXTENSION hstore;"

psql --username=postgres -d janmayen -f "C:\Users\redpa\Documents\FlightGear\osm2city-work\osmosis\script\pgsnapshot_schema_0.6.sql"

psql --username=postgres -d janmayen -f"C:\Users\redpa\Documents\FlightGear\osm2city-work\osmosis\script\pgsnapshot_schema_0.6_bbox.sql"


Then, downloading data from http://download.geofabrik.de/, navigating to Europe -> Norway and downloading the .pbf file: norway-latest.osm.pbf

I cropped it with osmosis as such:

cd Documents/FlightGear/osm2city-work/osmosis/bin/

osmosis --read-pbf file="C:/Users/redpa/Downloads/norway-latest.osm.pbf" --bounding-box completeWays=yes top=71.3 left=-9.5 bottom=70.7 right=-7.5 --write-pbf file="C:/Users/redpa/Downloads/norway-cropped.pbf"

Note that this can take up to ten - fifteen minutes. I used TerraGUI to get the coordinates, but any method will work.

And finally loaded it to the database:

osmosis --read-pbf file="C:/Users/redpa/Downloads/norway-cropped.pbf" --log-progress --write-pgsql database=janmayen host=localhost:5432 user=postgres password=YOURPW

and indexed the database:

psql --username=postgres --dbname=janmayen -c "CREATE INDEX idx_nodes_tags ON nodes USING gist(tags);"

psql --username=postgres --dbname=janmayen -c "CREATE INDEX idx_ways_tags ON ways USING gist(tags);"

psql --username=postgres --dbname=janmayen -c "CREATE INDEX idx_relations_tags ON relations USING gist(tags);"


Running osm2city

Next I create the params.ini file. For my purposes it is this - modify it according to docs at https://osm2city.readthedocs.io/en/latest/parameters.html

I ended up with: PREFIX = "JanMayen"

PATH_TO_SCENERY = "C:\\Users\\redpa\\Documents\\FlightGear\\TerraSync-b"

PATH_TO_OUTPUT = "C:\\Users\\redpa\\Documents\\FlightGear\\Custom Scenery\\JanMayen-OSM-fg-CustomScenery"

PATH_TO_OSM2CITY_DATA = "C:\\Users\\redpa\\Documents\\FlightGear\\osm2city-work\\osm2city-data"

NO_ELEV = False

FG_ELEV = "C:\\Users\\redpa\\Documents\\Programs\\FlightGear 2018.4.0\\bin\\fgelev.exe"

DB_HOST = "localhost"

DB_PORT = 5432

DB_NAME = "janmayen"

DB_USER = "postgres"

DB_USER_PASSWORD = ""

LOD_ALWAYS_ROUGH_ABOVE_LEVELS = 3

LOD_ALWAYS_DETAIL_BELOW_LEVELS = 1

LOD_PERCENTAGE_DETAIL = 0.6

BUILDING_NEVER_SKIP_LEVELS = 2

BUILDING_REDUCE_CHECK_TOUCH = True

BUILDING_SKEL_ROOFS_MIN_ANGLE = 15

BUILDING_MIN_AREA = 1

BUILDING_FORCE_EUROPEAN_INNER_CITY_STYLE = True

HIGHWAY_TYPE_MIN = 1

POINTS_ON_LINE_DISTANCE_MAX = 10

MIN_ABOVE_GROUND_LEVEL = 0.035

BRIDGE_MIN_LENGTH = 30

C2P_PROCESS_POWERLINES_MINOR = True

C2P_PROCESS_OVERHEAD_LINES = True

C2P_PROCESS_AERIALWAYS = True

C2P_PROCESS_STREETLAMPS = False

OVERLAP_CHECK_CONSIDER_SHARED = True

This goes in projects/JanMayen/params.ini Also, create the folder where you want osm2city to generate files - in my case: Documents/FlightGear/Custom Scenery/JanMayen-OSM-fg-CustomScenery

Then, finally, cd ../../projects

C:\Users\redpa\Documents\FlightGear\osm2city-work\osm2city\build_tiles.py -f JanMayen/params.ini -b *-9.5_70.7_-7.5_71.38 -p 1

Result

HYyyNb1.png