views:

381

answers:

7

What are some recommended frameworks for manipulating spatial data in C++?

I'm looking for a polygon object, point object, and some operations like union, intersection, distance, and area. I need to enter coordinates in WGS84 (lon,lat) and get area in square km.

I would prefer a free/open source framework, but am open to suggestions.

Edit: Unfortunately I need a non-GPL solution. LGPL is alright.

A: 

Depending on how complex these calculations are going to be you might want to consider writing your own. If you are just doing area that might be your best option for speed and lack of bloat.

otherwise the Geographic Foundation Class (GFC) library is your best bet.

Ben Jones
Thanks for the pointer to GFC. Unfortunately I need a non-GPL solution so I clarified my question.
Alex B
+3  A: 

GEOS is an open source (LGPL) C++ geometry / topology engine. Might suit you?

Useful places to look for this stuff are this useful article on the O'Reilly website and also OSGeo which is a collaboration to support open source geospatial stuff.

MarkJ
A: 

It's not comprehensive and high-level enough for what you asked, but for doing geodetic transforms you can use the NGA's excellent GEOTRANS library:

http://earth-info.nga.mil/GandG/geotrans/

That will let you convert between things like WGS84 lat/long and a local cartesian coordinate system. The C code is well tested, documented, and is public domain.

nsanders
+2  A: 
  • The CGAL Open Source Project provides easy access to efficient and reliable geometric algorithms in the form of a C++ library. CGAL is used in various areas needing geometric computation, such as: computer graphics, scientific visualization, computer aided design and modeling, geographic information systems, molecular biology, medical imaging, robotics and motion planning, mesh generation, numerical methods.

  • The Generic Geometry Library (geometrylibrary.geodan.nl, currently in "preview 4") provides a generic implementation of geometry algorithms, working with user-defined geometries. The algorithms include some well-known and often needed algorithms as point-in-polygon, polygon area, point-to-point distance, point-to-line distance, line clipping and polygon clipping, convex hulls. It also contains transformation algorithms, map projections and selection algorithms. Besides algorithms the library provides geometry classes which might be used, but the generic algorithms do not depend on them. (Proposed to be included in Boost)

e.tadeu
+1  A: 

GEOS for the Geometry model, and GDAL/OGR for a spatial data abstraction library which supports Rasters and Vectors.

By using these libraries, you will also be able to handle different coordinate systems (like transforming from/to WGS84) since both of them use Proj.4 under the hood. To find distances in meters you can transform from WGS84 to something that uses meters like UTM.

rburhum
A: 

I also recommend Generic Geometry Library which recently has been reviewed and eventually accepted to the collection of Boost C++ Libraries. As included in Boost, the GGL is now called Boost.Geometry, more precisely Boost.Geometry aka GGL, Generic Geometry Library.

Other useful tools

  • ORFEO Toolbox (aka OTB) - a library of image processing algorithm
  • MetaCRS - a project encompassing several projections, and coordinate system related technologies.
  • libgeotiff for sole GeoTIFF manipulation
mloskot