• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

long lat DB

 
david dabush
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I need to my server a local DB for mapping between long & lat to country. NOT API!!!
do you no any beside Maxmind? is there any free one?



Thanks,
David
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 3 elements to this functionality:

1. Spatial data.
2. Spatially aware database
3. Spatially aware query functions.

1. Spatial data

From what you say, it sounds like you want to be able to query with a long/lat point and find out which country contains that point e.g. (51N,1W) would be in the UK. You will need a set of data which holds the long/lat polygon (shape) coordinates for each country you're interested in e.g. if you lived in an imaginary square country, then the polygon would just have 4 pairs of coordinates. Unfortunately, real countries have much more complex shapes (and islands) which means their boundary polygons contain a lot more coordinates. The most widely used spatial data file format is probably ESRI's shapefile format, which most GIS (geographical information systems) products can read. You should be able to find one of these online e.g. here is a free shapefile with country boundaries and some other data. Once you have a suitable file, you will need a suitable place to put it so you can query it properly.

2. Spatially aware database

There are several free open source databases that can handle spatial data.

PostgreSQL is a mature and widely used relational (SQL) database that can be used for all kinds of applications, including GIS. If you decide to work with PostgreSQL, you will also need to install the PostGIS extensions (some PostgreSQL distributions may include this or you can install it yourself). PostGIS provides a lot of clever SQL extension functions that allow you to perform very rich queries on spatial data, combining spatial queries with regular SQL queries, as well as powerful indexing tools to make querying spatial data more efficient, and a range of functions to do things like converting between coordinate systems e.g. long/lat <--> Universal Transverse Mercator etc. PostgreSQL/PostGIS are widely used for GIS, and they are well documented online and in books, with lots of tutorials and examples.

MongoDB is another open source DB that can do some spatial queries, but the spatial functionality here is much less sophisticated than in PostgreSQL/PostGIS, and of course it is a NoSQL database so it may not be as easy to integrate with other parts of your application.

3. Spatially aware query functions

Your query needs to be able to handles questions like "what country contains the point (51N, 1W)?". In order to do this, the query tool needs to know how to interpret spatial data and also how to do so efficiently via spatial indexes. PostgreSQL/PostGIS and MongoDB can both do this, but they do so with very different query syntax. Unless you have a particular need to use MongoDB, I would recommend you try PostgreSQL/PostGIS because the spatial queries are easier to design, easier to implement and easier to integrate with other non-spatial queries. And of course there are lots of examples of how to do this with PostGIS e.g. this tutorialmight help you get started.

If you decide to use MongoDB, there are some basic tutorials on their website as well.

Hope this helps.
 
david dabush
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
chris webster wrote:There are 3 elements to this functionality:

1. Spatial data.
2. Spatially aware database
3. Spatially aware query functions.

1. Spatial data

From what you say, it sounds like you want to be able to query with a long/lat point and find out which country contains that point e.g. (51N,1W) would be in the UK. You will need a set of data which holds the long/lat polygon (shape) coordinates for each country you're interested in e.g. if you lived in an imaginary square country, then the polygon would just have 4 pairs of coordinates. Unfortunately, real countries have much more complex shapes (and islands) which means their boundary polygons contain a lot more coordinates. The most widely used spatial data file format is probably ESRI's shapefile format, which most GIS (geographical information systems) products can read. You should be able to find one of these online e.g. here is a free shapefile with country boundaries and some other data. Once you have a suitable file, you will need a suitable place to put it so you can query it properly.

2. Spatially aware database

There are several free open source databases that can handle spatial data.

PostgreSQL is a mature and widely used relational (SQL) database that can be used for all kinds of applications, including GIS. If you decide to work with PostgreSQL, you will also need to install the PostGIS extensions (some PostgreSQL distributions may include this or you can install it yourself). PostGIS provides a lot of clever SQL extension functions that allow you to perform very rich queries on spatial data, combining spatial queries with regular SQL queries, as well as powerful indexing tools to make querying spatial data more efficient, and a range of functions to do things like converting between coordinate systems e.g. long/lat <--> Universal Transverse Mercator etc. PostgreSQL/PostGIS are widely used for GIS, and they are well documented online and in books, with lots of tutorials and examples.

MongoDB is another open source DB that can do some spatial queries, but the spatial functionality here is much less sophisticated than in PostgreSQL/PostGIS, and of course it is a NoSQL database so it may not be as easy to integrate with other parts of your application.

3. Spatially aware query functions

Your query needs to be able to handles questions like "what country contains the point (51N, 1W)?". In order to do this, the query tool needs to know how to interpret spatial data and also how to do so efficiently via spatial indexes. PostgreSQL/PostGIS and MongoDB can both do this, but they do so with very different query syntax. Unless you have a particular need to use MongoDB, I would recommend you try PostgreSQL/PostGIS because the spatial queries are easier to design, easier to implement and easier to integrate with other non-spatial queries. And of course there are lots of examples of how to do this with PostGIS e.g. this tutorialmight help you get started.

If you decide to use MongoDB, there are some basic tutorials on their website as well.

Hope this helps.





Hi,
thanks for the answer but I am looking for a free tool to do that and not to implement it by myself. is there any free one?



 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you could explain what you are trying to do?

Your post seemed to be asking about using a local database to map from long/lat coordinates to country for free. If you don't want to implement a local DB service for this, and you don't want to use an API service, what is it that you expect to do here?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic