views:

492

answers:

5

What's a good library for geospatial functions? I mean things like

  • distance between two points on the globe
  • coordinates of a circle of a given radius from a particular point
  • etc.

Bonus if there's an interface to the various ways different databases represent geolocations.

I'm a geo-noob (in case this question didn't make it obvious), so pointers to other geolocation/geospatial resources are welcome.

C++ and Python preferred, but all pointers welcome.

+2  A: 

If you were using ruby with or without rails, I'd recommend the GeoKit gem: http://geokit.rubyforge.org/

Martin Dow
+4  A: 

Some options for functions from a useful article on the O'Reilly website. There are other options in the article.

  1. GEOS open source C++ geometry / topology engine. Might suit you?

  2. PostGIS - a PostgreSQL database that can also store geometric (spatial) data types. This provides GIS-like abilities within an SQL database environment, so you could do manipulations through SQL.

I'm not sure about interfaces to different databases but the article mentions a number of libraries that convert geospatial data between different formats. You might also be interested in the OGC standards. If all your target databases support WFS you should be able to access them with exactly the same code. EDIT: Increasing numbers of GIS packages support WFS but I don't think pure databases do.

EDIT: you could also check out OSGeo which is a collaboration to support open source geospatial stuff. FDO might do the interfaces to different databases.

MarkJ
+5  A: 

I've enjoyed using geopy. It's a simple library that finds great-circle distance in a number of projections. Geopy also provides a single interface to multiple geocoders like Google Maps and Microsoft Earth to give you coordinates for a street address.

You might be interested in the Topic :: Scientific/Engineering :: GIS section in PyPi.

joeforker
This seems to be 3 years old. Did Google Maps have geocoding back then?
webjunkie
geopy can do screen scraping as an alternative to official geocoding APIs, but it works fine with Google's (and Yahoo,and MS, and ...) real geocoding API, too.
joeforker
okay, this is awesome. like python always is. thanks!
webjunkie
+1  A: 

I was looking at something similar, there's the Geolocator Library that I found, it provides some distance calculation functions.

+1  A: 

Check GDAL/OGR which is two libraries in one - GDAL for raster data and OGR for vector data. The OGR part provides API to manipulate geometries - it uses GEOS library.

mloskot