pelias / api

HTTP API for Pelias Geocoder
http://pelias.io
MIT License
219 stars 162 forks source link

query all postalcodes from geonames #1277

Open woiza opened 5 years ago

woiza commented 5 years ago

Is it possible to get all geonames postalcodes and their coordinates for a specified (e.g. Belgium) country?

NickStallman commented 5 years ago

The Who's on First importer should provide postal codes if you enable imports.whosonfirst.importPostalcodes

woiza commented 5 years ago

I imported Whosonfirst postalcodes for Belgium and can get coordinates for complete postal codes, e.g. http://localhost:3900/v1/search/structured?postalcode=1180 --> "coordinates": [4.361377,50.789864]

I am trying to achieve routing with 2 digit postal codes, e.g. from 11 to 13 in Belgium. In order to do so I have to calculate the centroids of 11 and 13 using the coordinates of all 11xx postal codes and 13xx postal codes. However, I have no clue how to get these coordinates. Any ideas?

NickStallman commented 5 years ago

So you want to enumerate all the postcodes by their first two digits, then compute a central centoid of all of them?

I don't think Pelias can help there, you'd want a kind of numeric wildcard so you can search for postalcode=11## to get the list.

However you can get this from the Who's on First dataset, and you don't even need to touch the json files. The meta file contains all the postcodes and their centroid and is in CSV format. Simply import the Belgium postalcodes meta file in to a regular database and you'll be able to go from there. It'll probably be simpler and faster that way too.

woiza commented 5 years ago

That was my first idea too. I was hoping there was a more "elegant" solution without additional databases/storage. Thanks for your help, much appreciated.