Preliminary use of Postgres and OSM

Source: Internet
Author: User
Tags polyline postgresql postgres database

Layout:post
Preliminary use of Title:postgres and OSM
Date:2016-9-20
Categories:blog
Tags: [map development] Description: Map Development

This paper mainly includes the following content PostgreSQL database, used to store map raw data osm2pgsql used to import OSM map data into PostgreSQL

OSM Data

OpenStreetMap (OSM) is an online map (crowd sourcing) project that aims to create a world map free of content that allows everyone to edit

OSM Data features diverse data sources, massive data but uneven data quality (errors, inconsistencies), a large number of subsequent data processing in accordance with the category of data, with different labels labeled data categories to compile the data, according to the global (Planet OSM, OSM) or regional release File size: XML variant over 600+GB uncompressed, 50+ GB bz2 compressed and 30+GB for PBF

OpenStreetMap includes spatial data and attribute data. The spatial data mainly includes three kinds: Point (Nodes), Road (Ways) and Relation (Relations), these three kinds of original form the whole map picture. Where the nodes defines the location of the midpoint of the space; ways defines the line or region; Relations (optional) defines the relationship between elements, and the attribute data tags are used to describe the vector data primitives

node defines a geographical coordinate point by latitude. At the same time, can also height= mark the elevation of the object, through layer= and level=, you can indicate the map level of the object and the number of layers in the building, through place= and name=* to represent the name of the object. At the same time, way is also formed by connecting multiple points (node) into lines (faces).

The way is formed by 2-2000 dots (nodes). Way can represent the following 3 graphical objects (closed lines (Open polyline), closed lines (Closed polyline), Region (area). For more than nodes way, can be processed by segmentation.

OSM Classification features and tags (tag)

Each feature the data by tag to record the data through ' key ' and a ' value '. For example, you can define a residential road by Highway=residential, and you can use additional namespaces to add additional information, such as: maxspeed:winter=* means the maximum speed limit in winter

Postgressql Database Installation

Open source free database: PostgreSQL Download Installation Tutorial _ Baidu Experience OSM data Extraction

Download Osm:http://dev.openstreetmap.org/~bretth/osmosis-build/osmosis-latest.zip

download China map data
Http://download.geofabrik.de/asia/china.html

Data cropping

Regional cut, cut the map of China into Wuhan map:

Osmosis--READ-PBF file= "CHINA-LATEST.OSM.PBF"--used-node--bounding-box left=113.9502 right=114.4762 top=30.7643 bottom=30.4291 clipincompleteentities= "true"--WRITE-PBF WUHAN.PBF

Expressway data extraction from Wuhan map

Osmosis--READ-PBF file= "WUHAN.PBF"--TF accept-ways highway=* clipincompleteentities= "true"--WRITE-PBF Wuhan_ Highway.pbf

import data into Postgres database create extension hstore; Create extension PostGIS; Create extension pgrouting; Run Database Ddl:pgsnapshot_schema_0.6.sql

Import data: OSMOSIS–READ-PBF file= "WUHAN_HIGHWAY.PBF" –wp host=localhost database=osm user=postgres password=postgres First, add 3 extensions to the Postgres and run the Pgsnapshot_schema_0.6.sql script under the Osmosis-latest\script folder to run the import command.

install Qgis and connect Postgres can see the imported data on the map

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.