I'm trying to write a simple C program that creates and populates a shapefile (have one done in python). I'm very new to C and GDAL both and could use some help. I'm trying to apply coordinatetransformation to my points but first I have to create the coordinatetransformation. In python I can do this simply by: coordtrans = osr.CoordinateTransformation(target, source) but in C I cant seem to find the right call for this. Any ideas?
#include "ogr_api.h" #include "ogr_srs_api.h" int main() { //~ variable declaration const char *format = "ESRI Shapefile", *name = "testc.shp", *source, *target; const char *sprj = "+proj=lcc +lat_1=33.000000 +lat_2=45.000000 +lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0 +datum=NAD83"; const char *tprj = "WGS84"; OGRSFDriverH driver; OGRDataSourceH ds; OGRCoordinateTransformation ctrans; //~ get driver and create ds OGRRegisterAll(); driver = OGRGetDriverByName(format); ds = OGR_Dr_CreateDataSource(driver, "testc.shp", NULL); //~ create spatrefs and trans OSRNewSpatialReference(source); OSRNewSpatialReference(target); OSRSetFromUserInput(source, sprj); OSRSetFromUserInput(target, tprj); ctrans = OGRCreateCoordinateTransformation(target, source); } [t...@updraft ~/Programs]$ gcc -o gdal_test_convert gdal_test_convert.c gdal_test_convert.c: In function ‘main’: gdal_test_convert.c:12: error: ‘OGRCoordinateTransformation’ undeclared (first use in this function) gdal_test_convert.c:12: error: (Each undeclared identifier is reported only once gdal_test_convert.c:12: error: for each function it appears in.) gdal_test_convert.c:12: error: expected ‘;’ before ‘ctrans’ gdal_test_convert.c:22: warning: passing argument 1 of â €˜OSRSetFromUserInput’ discards qualifiers from pointer target type gdal_test_convert.c:23: warning: passing argument 1 of â €˜OSRSetFromUserInput’ discards qualifiers from pointer target type gdal_test_convert.c:24: error: ‘ctrans’ undeclared (first use in this function) _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev