8

I was planning to use geonames API but actually it seems far more sensible to use the geonames locally and not use their web API. So my question is, does anyone know how to interface with the geonames data locally?

Do I need to manually import it into a database and then reference it like a normal DB?

Jimmy
  • 12,087
  • 28
  • 102
  • 192

1 Answers1

6

Yes you will have to import the database manually if you want to query the database locally.

1 - If you plan to use MySQL you can follow the explanations from this post Importing data from geonames.org database into MySQL DB

2 - If the table structure is not up to date you can also refer to the GeoNames forum: http://forum.geonames.org/gforum/posts/list/732.page

3 - Once you have created your tables following the given structure you can use LOAD DATA INFILE or LOAD DATA LOCAL INFILE to bulk import the data from the CSV files.

4 - The importation of the allcountries table can take more than 10 minutes locally. It might be better to create your indexes before you import the data.

(A shell Script is also available if you are familiar with the command)

Community
  • 1
  • 1
RafaSashi
  • 16,483
  • 8
  • 84
  • 94
  • 1
    How accurate is the city database, i'm thinking about using it. I don't mind paying for something more accurate i just need to pointed in the right direction. – David Apr 20 '15 at 05:29
  • 1
    The city database is accurate even for small ones. There is more alternatives provided by the geohack project for example http://tools.wmflabs.org/geohack/geohack.php?pagename=New_York_City&params=40.7127_N_74.0059_W_type:city_region:US-NY – RafaSashi Apr 20 '15 at 07:20