Update 'Dump OSM data to a postgis database'
parent
b250fdcaf0
commit
328f276d07
|
@ -92,4 +92,21 @@ wget https://download.openstreetmap.fr/extracts/north-america/mexico-latest.osm.
|
|||
sudo -u postgres osm2pgsql --create --database pgsnapshot --cache 20000 --number-processes 2 --slim -P 5435 --keep-coastlines --extra-attributes --hstore-all mexico-latest.osm.pbf
|
||||
```
|
||||
|
||||
Then change the postgresql.conf and pg_hba.conf files to allow remote connections to the database.
|
||||
Then change the postgresql.conf and pg_hba.conf files to allow remote connections to the database.
|
||||
|
||||
## Interesting Postgis features
|
||||
|
||||
You can compute minimum distances with KNN as follows:
|
||||
|
||||
```
|
||||
select
|
||||
st_distance(st_transform(st_setsrid(st_point(-120, 12), 4326), 3857), way) as distance
|
||||
from
|
||||
public.planet_osm_roads
|
||||
where
|
||||
highway in ('motorway', 'trunk', 'primary', 'secondary')
|
||||
order by
|
||||
st_transform(st_setsrid(st_point(-120, 12), 4326), 3857) <-> way
|
||||
limit
|
||||
1
|
||||
```
|
Loading…
Reference in a new issue