I posted this a couple of weeks ago, and got no replies. I'm trying
again with a (perhaps) better subject line...
I have some satellite imagery that I am trying to process into
Geotiffs. The problem I'm having is that when GeotiffWriter tries to
create a MapProjection, the parseProjection method in
CRS2GeotiffMetadataAdapter throws a ClassCastException because
(apparently) it can't get to a proper MapProjection from my CRS. The
data comes to me in a Lambert Conic Conformal (1SP) projection that does
not appear to have any EPSG code, so I create a CRS with some WKT, and
parse it with CRS.parseWKT(String).
I'm attaching a bit of code I wrote to mimic what
CRS2GeotiffMetadataAdapter does to try and get from the CRS to a
MapProjection. My "User Defined" CRS is in the code. I can only assume
that something is wrong with my CRS definition. Any ideas?
Matt
--
Do not go where the path may lead; go instead where there is no path and leave
a trail.
-- Ralph Waldo Emerson
import org.geotools.referencing.CRS;
import org.geotools.referencing.operation.projection.MapProjection;
import org.geotools.referencing.operation.transform.ConcatenatedTransform;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.operation.Conversion;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.OperationMethod;
/**
*
* @author mwfoster
*/
public class CRSTest {
public CRSTest() {
doTest();
}
private void doTest() {
String wkt = "PROJCS[\"WGS84 / Central US LCC\"," +
"GEOGCS[\"WGS 84\"," +
"DATUM[\"WGS_1984\"," +
"SPHEROID[\"WGS 84\",6378137,298.257223563," +
"AUTHORITY[\"EPSG\",\"7030\"]]," +
"TOWGS84[0,0,0,0,0,0,0]," +
"AUTHORITY[\"EPSG\",\"6326\"]]," +
"PRIMEM[\"Greenwich\",0.0,AUTHORITY[\"EPSG\",\"8901\"]]," +
"UNIT[\"degree\",0.017453292519943295]," +
"AXIS[\"Geodetic latitude\",NORTH]," +
"AXIS[\"Geodetic longitude\",EAST]," +
"AUTHORITY[\"EPSG\",\"4326\"]]," +
"PROJECTION[\"Lambert Conic Conformal
(1SP)\",AUTHORITY[\"EPSG\",\"9801\"]]," +
"PARAMETER[\"latitude_of_origin\",25.0]," +
"PARAMETER[\"central_meridian\",-95.0]," +
"PARAMETER[\"scale_factor\",1]," +
"PARAMETER[\"false_easting\",0.0]," +
"PARAMETER[\"false_northing\",0.0]," +
"UNIT[\"km\",1000]," +
"AXIS[\"Easting\", EAST]," +
"AXIS[\"Northing\", NORTH]]";
CoordinateReferenceSystem crs = null;
//System.out.println(wkt);
try {
crs = CRS.parseWKT(wkt);
//crs = CRS.decode("EPSG:2767");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
System.out.println("CRS: \n" + crs.toWKT());
ProjectedCRS pcrs = (ProjectedCRS) crs;
Conversion conv = pcrs.getConversionFromBase();
System.out.println("Conversion name: " + conv.getName().getCode());
OperationMethod method = conv.getMethod();
System.out.println("Op Method: " + method.getName().getCode());
MathTransform mt = conv.getMathTransform();
if (mt instanceof ConcatenatedTransform) {
System.out.println("It's a CT");
} else {
System.out.println("It's not a CT");
}
ConcatenatedTransform ct = (ConcatenatedTransform) mt;
//System.out.println("CT WKT: " + ct.toWKT());
MathTransform m1 = ct.transform1, m2 = ct.transform2;
System.out.println("M1: " + m1.toWKT());
System.out.println("M2: " + m2.toWKT());
if (m1 instanceof MapProjection) {
System.out.println("M1 is an MP");
} else if (m2 instanceof MapProjection) {
System.out.println("M2 is an MP");
} else {
System.out.println("Bummer");
}
}
public static void main(String[] argv) {
new CRSTest();
}
}
begin:vcard
fn:Matt Foster - N0EYE
n:Foster;Matt
org:;NWS Forecast Office - Norman OK
email;internet:[EMAIL PROTECTED]
title:Information Technology Officer
tel;work:(405) 325-3406
x-mozilla-html:TRUE
version:2.1
end:vcard
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users