Dear All -- First of all: This is my first posting to this list, and I would like to take the opportunity and say a big "Thank You" to the developers of GeoTools! Your library has allowed me to do some immensely productive Java GIS coding.
But now I've run into a dead end (or so it seems). I am trying to use GeoTools' "ProjectiveTransform(Builder)" classes to transform the pixel coordinates of images to real-world coordinates. I made some tests with "AffineTransform" first and this worked fine, but the images have a perspective distortion and a simple affine transformation won't suffice. Then I tested "ProjectiveTransform" with some synthetic data, and the results looked promising. However, with real data, the transformation seems to go out of control. Below is a list of six points. On line "Transform", you will find the image coordinates and the world coordinates to which they are _supposed_ to map. Under "World", you find the _actual_ mappings and the difference (in map units, meters). As you can see, the two are way off, with a maximum distance of 278 meters. Also note the huge RMS: PROJECTIVE FORWARD RESULTS (IMAGE TO WORLD): RMS = 134.46109310005252 Pt.: 1 Transform: 138.2/385.3 -> 513356.295/280624.993. World X = 513393.74146133795 (37.446461337967776). World Y = 280638.165346099 (13.172346098988783). Dist = 39.695694583763874 Pt.: 2 Transform: 1267.3/415.3 -> 513357.71/280624.795. World X = 513482.11524025456 (124.40524025453487). World Y = 280597.9072626728 (-26.8877373271971). Dist = 127.2777051229511 Pt.: 3 Transform: 2516.7/509.4 -> 513359.273/280624.553. World X = 513583.4260212551 (224.1530212551006). World Y = 280556.36530408286 (-68.18769591714954). Dist = 234.294982473546 Pt.: 4 Transform: 2517.4/1589.3 -> 513359.071/280623.21. World X = 513637.1007852404 (278.0297852404183). World Y = 280607.33684666886 (-15.873153331165668). Dist = 278.48252813687935 Pt.: 5 Transform: 1510.2/1744.6 -> 513357.854/280623.122. World X = 513573.2481027579 (215.39410275791306). World Y = 280647.9796511657 (24.857651165744755). Dist = 216.82371255092065 Pt.: 6 Transform: 237.0/1685.9 -> 513356.421/280623.314. World X = 513480.8793013462 (124.4583013462252). World Y = 280688.37563165755 (65.06163165753242). Dist = 140.43818813958055 Now, I have tested the same data with QGIS and its projective referencing mode and it manages to hit the target spot-on. So the problem is not that the image is too distorted for a projective transform. The RMS should be at most a few cm. Also, if I scale the pixel coordinates to bring them roughly into the same range as the real-world coordinates (say multiply by one million), then I get substantially better results (however, results are still off the mark by several meters). This leads me to suspect that there is a precision problem involved here. I use a "ProjectiveTransformBuilder" with a list of "MapPosition" to build the "ProjectiveTransform". I have tried toying with "MappedPosition.setAccuracy(double)", but no luck (I also don't understand how to set the double parameter). I have tested GeoTools 11 through 13 and am getting the same results with each. If anyone could point me into the right direction for solving this problem, I would be very grateful. I will gladly elaborate and also send sample data via PM if anyone wants to take a closer look. Thanks and best regards, Ben -- Dr. Benjamin Ducke {*} Geospatial Consultant {*} GIS Developer Spatial technology for the masses, not the classes: experience free and open source GIS at http://gvsigce.org ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users