= GDAL FAQ = 1. [wiki:FAQGeneral General] 2. [wiki:FAQInstallationAndBuilding] 3. [wiki:FAQRaster] 4. [wiki:FAQVector] 5. [wiki:FAQCoordinateSystemsAndProjections] 6. [wiki:FAQMiscellaneous] == Raster Support == === Why won't gdalwarp or gdal_merge write to most formats? === GDAL supports many raster formats for reading, but significantly less formats for writing. Of the ones supported for writing most are only supported in create copy mode. Essentially this means they have to be written sequentially from a provided input copy of the image to be written. Programs like gdal_merge.py or gdalwarp that write chunks of imagery non-sequentially cannot easily write to these sequential write formats. Generally speaking formats that are compressed, such as PNG, JPEG and GIF are sequential write. Also some formats require information such as the coordinate system and color table to be known at creation time and so these are also sequential write formats. When you encounter this problem it is generally a good idea to first write the result to GeoTIFF format, and then translate to the desired target format. To determine which formats support which capabilities, use the ''--formats'' switch with pretty much any GDAL utility. Each driver will include either '''r''' (read-only), '''rw''' (read or sequential write) or '''rw+''' (read, sequential write or random write). === How to convert a raster to a layer of polygons? === ''TBD'' == Vector Support == ''TBD'' == Coordinate Systems and Projections == === What are ''Well Known Text'' projections, and how do I use them? === ''OpenGIS Well Known Text'' is a textual format for defining coordinate systems. It is loosely based on the [http://www.epsg.org/ EPSG] coordinate systems model. While GDAL itself just passes these definitions around as text strings, there is also an [http://www.gdal.org/ogr/classOGRSpatialReference.html OGRSpatialReference] class in ''gdal/ogr'' for manipulating them and a linkage to [http://proj.maptools.org/ PROJ.4] for transforming between coordinate systems. The OGRSpatialReference, and PROJ.4 linkaged (but not PROJ.4 itself) is linked into the GDAL shared library by default. More documentation on WKT and OGRSpatialReference can be found in the [http://www.gdal.org/ogr/osr_tutorial.html OGR Projections Tutorial]. === Can I reproject rasters with GDAL? === Yes, you can use the gdalwarp utility program or programmatically use the [http://www.gdal.org/classGDALWarpOperation.html GDALWarpOperation] class described in the [http://www.gdal.org/warptut.html GDAL Warp API Tutorial]. == Miscellaneous == === Is the GDAL library thread-safe? === No. GDAL is not completely thread safe. However for GDAL 1.3.0 much work has been done on making some common scenarios thread safe. In particular for the situation where many threads are reading from GDAL datasets at once should work as long as no two threads access the same [http://www.gdal.org/classGDALDataset.html GDALDataset] object at the same time. However, in this scenario, no threads can be writing to GDAL while others are reading or chaos may ensue. Also, while the GDAL core infrastructure is now thread-safe for this specific case, only a few drivers have been vetted to be thread safe. It is intended that work will continue on improving GDAL's thread safety in future versions. === Does GDAL work in different international numeric locales? === No. GDAL makes extensive use of ''sprintf()'' and ''atof()'' internally to translate numeric values. If a locale is in effect that modifies formatting of numbers, altering the role of commas and periods in numbers, then PROJ.4 will not work. This problem is common in some European locales. On Unix-like platforms, this problem can be avoided by forcing the use of the default numeric locale by setting the ''LC_NUMERIC'' environment variable to ''C'', e.g. {{{ $ export LC_NUMERIC=C $ gdalinfo abc.tif }}} === How do I debug GDAL? === Various helpful debugging information will be produced by GDAL and OGR if the ''CPL_DEBUG'' environment variable is set to the value ''ON''. Review the documentation for the [http://www.gdal.org/ogr/cpl__error_8h.html CPLDebug()] function for more information on built-in debugging messages. On Unix operating systems GDAL can be built with the ''CFG'' environment variable set to ''debug'' to enable debugger support with the ''-g'' compiler switch. On Windows edit the nmake.opt and ensure ''/Zi'' appears in the ''OPTFLAGS'' variable. === How should I deallocate resources acquainted from GDAL on Windows? === The safest way to release resources allocated and returned (with ownership transfered to caller) from GDAL library is to use dedicated deallocator function. Deallocators promise to release resources on the right module side, without crossing modules boundaries what usually causes memory access violation errors. * Example of correct resource deallocation: {{{ OGRDataSource* poDS = NULL; // OGRDataSource aquisition made on side of the GDAL module poDS = OGRSFDriverRegistrar::Open( "point.shp", FALSE ); // ... // Properly resource release using deallocator function OGRDataSource::DestroyDataSource( poDS ); }}} * Example of incorrect resource deallocation: {{{ OGRDataSource* poDS = NULL; // OGRDataSource aquisition made on side of the GDAL module poDS = OGRSFDriverRegistrar::Open( "point.shp", FALSE ); // ... // Deallocation across modules boundaries. // Here, the deallocation crosses GDAL DLL library and client's module (ie. executable module) delete poDS; }}} More detailed explanation of the problem can be found in the [http://blogs.msdn.com/oldnewthing/archive/2006/09/15/755966.aspx Allocating and freeing memory across module boundaries] article.