How can I store roadmaps in postGIS?

How to export OSM roadmap to postGIS database? Also, if I have the coordinates of the intersections, can I get the section of the road that I need?

Any help would be greatly appreciated. Thank!

+3


source to share


1 answer


You can use the osm2pgsql tool which supports osm xml (* .osm).

Primary use:

osm2pgsql -d your_geo_database your-osm-data.osm.bz2

      

This command will import the file your-osm-data.osm.bz2

into the database your_geo_database

.

The database must exist and the postgis extension must be loaded.

Yes, you can only import a portion of your osm data by specifying the bounding box you want to import with a parameter --bbox

and coordinates separated by commas like minlon, minlat, maxlon, maxlat, ie:

osm2pgsql -l -d your_geo_database --boxx -0.5,51.25,0.5,51.75 you-osm-data.osm.bz2

      

You cannot specify the section of roads you need using a point, but you can draw a bounding box around that point, i.e. square 100m X 100m



A type

osm2pgsql --help

      

to view all options.

The same important parameters are:

-l

: save data in latitude and longitude (srid 4326)

-a

: Add OSM file to database without deleting existing data.

-d -H -U -W -P

: database connection parameters: database name, host, username, password, port.

If your osm file is too large, you probably have to use some options that optimize memory usage, i.e .: --cache-strategy

, --slim

or--unlogged

+5


source







All Articles