---------- Forwarded message ----------
From: Simone Giannecchini <[EMAIL PROTECTED]>
Date: Nov 10, 2006 4:19 PM
Subject: Re: [Geotools-gt2-users] GeoTIFF writer only works with EPSG CRS?
To: Christopher Hammack <[EMAIL PROTECTED]>
Ciao Christopher,
I tried your tiff with the latest source code of geotools 2.3.x on my
win xp box and it works fine. Here is the output of the test:
.10-nov-2006 16.16.57 org.geotools.gce.geotiff.GeoTiffReaderTest testReader
INFO:
E:\Work\gt-2.3.x\plugin\geotiff\target\test-classes\org\geotools\gce\geotiff\test-data\test.tif
ACCEPTED
CRS: GEOGCS["WGS 84",
DATUM["World Geodetic System 1984",
SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic longitude", EAST],
AXIS["Geodetic latitude", NORTH],
AUTHORITY["EPSG","4326"]]
TIFF metadata: <com_sun_media_imageio_plugins_tiff_image_1.0>
<TIFFIFD
tagSets="com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet,com.sun.media.imageio.plugins.tiff.FaxTIFFTagSet,com.sun.media.imageio.plugins.tiff.EXIFParentTIFFTagSet,com.sun.media.imageio.plugins.tiff.GeoTIFFTagSet">
<TIFFField number="256" name="ImageWidth">
<TIFFShorts>
<TIFFShort value="170"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="257" name="ImageLength">
<TIFFShorts>
<TIFFShort value="170"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="258" name="BitsPerSample">
<TIFFShorts>
<TIFFShort value="8"/>
<TIFFShort value="8"/>
<TIFFShort value="8"/>
<TIFFShort value="8"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="259" name="Compression">
<TIFFShorts>
<TIFFShort value="1" description="Uncompressed"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="262" name="PhotometricInterpretation">
<TIFFShorts>
<TIFFShort value="2" description="RGB"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="273" name="StripOffsets">
<TIFFLongs>
<TIFFLong value="454"/>
<TIFFLong value="8614"/>
<TIFFLong value="16774"/>
<TIFFLong value="24934"/>
<TIFFLong value="33094"/>
<TIFFLong value="41254"/>
<TIFFLong value="49414"/>
<TIFFLong value="57574"/>
<TIFFLong value="65734"/>
<TIFFLong value="73894"/>
<TIFFLong value="82054"/>
<TIFFLong value="90214"/>
<TIFFLong value="98374"/>
<TIFFLong value="106534"/>
<TIFFLong value="114694"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="277" name="SamplesPerPixel">
<TIFFShorts>
<TIFFShort value="4"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="278" name="RowsPerStrip">
<TIFFShorts>
<TIFFShort value="12"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="279" name="StripByteCounts">
<TIFFLongs>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="8160"/>
<TIFFLong value="1360"/>
</TIFFLongs>
</TIFFField>
<TIFFField number="282" name="XResolution">
<TIFFRationals>
<TIFFRational value="1/1"/>
</TIFFRationals>
</TIFFField>
<TIFFField number="283" name="YResolution">
<TIFFRationals>
<TIFFRational value="1/1"/>
</TIFFRationals>
</TIFFField>
<TIFFField number="296" name="ResolutionUnit">
<TIFFShorts>
<TIFFShort value="1" description="None"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="338" name="ExtraSamples">
<TIFFShorts>
<TIFFShort value="2" description="Unassociated Alpha"/>
</TIFFShorts>
</TIFFField>
<TIFFField number="33550" name="ModelPixelScaleTag">
<TIFFDoubles>
<TIFFDouble value="0.1"/>
<TIFFDouble value="0.1"/>
<TIFFDouble value="0.0"/>
</TIFFDoubles>
</TIFFField>
<TIFFField number="33922" name="ModelTiePointTag">
<TIFFDoubles>
<TIFFDouble value="0.0"/>
<TIFFDouble value="0.0"/>
<TIFFDouble value="0.0"/>
<TIFFDouble value="119.0"/>
<TIFFDouble value="47.0"/>
<TIFFDouble value="0.0"/>
</TIFFDoubles>
</TIFFField>
<TIFFField number="34735" name="GeoKeyDirectory">
<TIFFShorts>
<TIFFShort value="1"/>
<TIFFShort value="1"/>
<TIFFShort value="2"/>
<TIFFShort value="3"/>
<TIFFShort value="1024"/>
<TIFFShort value="0"/>
<TIFFShort value="1"/>
<TIFFShort value="2"/>
<TIFFShort value="1025"/>
<TIFFShort value="0"/>
<TIFFShort value="1"/>
<TIFFShort value="1"/>
<TIFFShort value="2048"/>
<TIFFShort value="0"/>
<TIFFShort value="1"/>
<TIFFShort value="4326"/>
</TIFFShorts>
</TIFFField>
</TIFFIFD>
</com_sun_media_imageio_plugins_tiff_image_1.0>
On sunday I will test the tiff on my linux box ( I am out until then
and I have no access to a linux box) to see if it works there.
We fixed a bug on the geotiff reader a couple of days ago. I suspect
you are running into it if you are using geotools2.3.m0.
Next week we should release an improved 2.3.x version of geotools.
Simone.
On 11/10/06, Christopher Hammack <[EMAIL PROTECTED]> wrote:
> You actually get two success messages?
>
> I get this exception:
>
> Test1: Success!
> Exception in thread "main" java.lang.NullPointerException
> at
> org.geotools.gce.geotiff.GeoTiffException.getMessage(GeoTiffException.java:202)
> at
> org.geotools.data.DataSourceException.<init>(DataSourceException.java:47)
> at
> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:211)
>
> When using the attached file. (Note the spatial coordinates don't
> actually make sense in this test case--but since it's treated as a pure
> raster it should work).
>
> Thanks,
>
> -cnh
>
>
>
>
> > Ciao Christopher,
> > I did some quick tests on windows box yesterday and everything worked.
> >
> > Tomorrow I will test the code on ,my brand new linux box to see if
> > there are problems there.
> >
> > Aside from this, it is not clear to me what you are trying to do.
> > Could you provide some details on this code?
> >
> >
> > Simone.
> >
> > On 11/6/06, Christopher Hammack <[EMAIL PROTECTED]> wrote:
> >> Thank you for responding.
> >>
> >> Here is some sample code. I can't seem to make it work with any non
> >> EPSG
> >> CRS. I compiled against 2.3M0.
> >>
> >>
> >> Code below:
> >>
> >> import java.awt.image.RenderedImage;
> >> import java.io.File;
> >> import java.io.IOException;
> >>
> >> import javax.imageio.ImageIO;
> >>
> >> import org.geotools.coverage.grid.GridCoverage2D;
> >> import org.geotools.coverage.grid.GridCoverageFactory;
> >> import org.geotools.data.coverage.grid.GridCoverageReader;
> >> import org.geotools.gce.geotiff.GeoTiffFormat;
> >> import org.geotools.gce.geotiff.GeoTiffReader;
> >> import org.geotools.gce.geotiff.GeoTiffWriter;
> >> import org.geotools.geometry.DirectPosition2D;
> >> import org.geotools.geometry.GeneralEnvelope;
> >> import org.geotools.referencing.CRS;
> >> import org.geotools.referencing.crs.DefaultGeographicCRS;
> >> import org.opengis.coverage.grid.GridCoverage;
> >> import org.opengis.referencing.FactoryException;
> >> import org.opengis.referencing.crs.CoordinateReferenceSystem;
> >> import org.opengis.referencing.operation.MathTransform;
> >> import org.opengis.referencing.operation.TransformException;
> >> import org.opengis.spatialschema.geometry.MismatchedDimensionException;
> >>
> >> import com.vividsolutions.jts.geom.Coordinate;
> >>
> >> public class TestGeoTIFF {
> >>
> >> private static void testWorks() {
> >> try {
> >> // Pre-requisites
> >> GridCoverageFactory gcf = new
> >> GridCoverageFactory();
> >> RenderedImage ri = ImageIO
> >> .read(new
> >> File("/home/chammack/test.tif"));
> >> DirectPosition2D dp1 = new DirectPosition2D(
> >> DefaultGeographicCRS.WGS84, -80,
> >> 50);
> >> DirectPosition2D dp2 = new DirectPosition2D(
> >> DefaultGeographicCRS.WGS84, -70,
> >> 40);
> >>
> >> CoordinateReferenceSystem crs1 =
> >> CRS.decode("EPSG:3033");
> >> MathTransform mt = CRS.findMathTransform(
> >> DefaultGeographicCRS.WGS84, crs1,
> >> true);
> >>
> >> GeneralEnvelope ge = new GeneralEnvelope(2);
> >> ge.setCoordinateReferenceSystem(crs1);
> >> ge.add(mt.transform(dp1, new
> >> DirectPosition2D()));
> >> ge.add(mt.transform(dp2, new
> >> DirectPosition2D()));
> >>
> >> GridCoverage2D gc1 = gcf.create("test", ri, ge);
> >>
> >> File f = new File("/home/chammack/geotiff1.tif");
> >> GeoTiffWriter gtw = new GeoTiffWriter(f);
> >> gtw.write(gc1, null);
> >>
> >> GeoTiffReader gr = new GeoTiffReader(f, null);
> >> GridCoverage gc2 = gr.read(null);
> >>
> >> System.out.println("Test1: Success!");
> >>
> >> } catch (MismatchedDimensionException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (IllegalArgumentException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (IndexOutOfBoundsException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (IOException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (FactoryException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (TransformException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> }
> >> }
> >>
> >>
> >> private static void testFails() {
> >> try {
> >>
> >> String wkt = "PROJCS[\"Lambert Conformal\",
> >> GEOGCS[\"WGS84\",
> >> DATUM[\"WGS84\", SPHEROID[\"WGS84\", 6378137.0, 298.257223563],
> >> TOWGS84[0,0,0]], PRIMEM[\"Greenwich\", 0.0], UNIT[\"degree\",
> >> 0.017453292519943295], AXIS[\"Geodetic longitude\", EAST],
> >> AXIS[\"Geodetic latitude\", NORTH]],
> >> PROJECTION[\"Lambert_Conformal_Conic_2SP\"],
> >> PARAMETER[\"central_meridian\", -95.0],
> >> PARAMETER[\"latitude_of_origin\", 25.0],
> >> PARAMETER[\"standard_parallel_1\", 25.0], PARAMETER[\"false_easting\",
> >> 0.0], PARAMETER[\"false_northing\", 0.0],
> >> PARAMETER[\"standard_parallel_2\", 25.0], UNIT[\"m\", 1.0],
> >> AXIS[\"Easting\", EAST], AXIS[\"Northing\", NORTH]]";
> >>
> >> // Pre-requisites
> >> GridCoverageFactory gcf = new
> >> GridCoverageFactory();
> >> RenderedImage ri = ImageIO
> >> .read(new
> >> File("/home/chammack/test.tif"));
> >> DirectPosition2D dp1 = new DirectPosition2D(
> >> DefaultGeographicCRS.WGS84, -80,
> >> 50);
> >> DirectPosition2D dp2 = new DirectPosition2D(
> >> DefaultGeographicCRS.WGS84, -70,
> >> 40);
> >>
> >> CoordinateReferenceSystem crs1 =
> >> CRS.parseWKT(wkt);
> >> MathTransform mt = CRS.findMathTransform(
> >> DefaultGeographicCRS.WGS84, crs1,
> >> true);
> >>
> >> GeneralEnvelope ge = new GeneralEnvelope(2);
> >> ge.setCoordinateReferenceSystem(crs1);
> >> ge.add(mt.transform(dp1, new
> >> DirectPosition2D()));
> >> ge.add(mt.transform(dp2, new
> >> DirectPosition2D()));
> >>
> >> GridCoverage2D gc1 = gcf.create("test", ri, ge);
> >>
> >> File f = new File("/home/chammack/geotiff1.tif");
> >> GeoTiffWriter gtw = new GeoTiffWriter(f);
> >> gtw.write(gc1, null);
> >>
> >> GeoTiffReader gr = new GeoTiffReader(f, null);
> >> GridCoverage gc2 = gr.read(null);
> >> System.out.println("Test2: Success!");
> >>
> >> } catch (MismatchedDimensionException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (IllegalArgumentException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (IndexOutOfBoundsException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (IOException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (FactoryException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> } catch (TransformException e) {
> >> // TODO Auto-generated catch block
> >> e.printStackTrace();
> >> }
> >> }
> >>
> >>
> >> public static void main(String[] args) {
> >>
> >> testWorks();
> >> testFails();
> >> }
> >> }
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> > CIao Christopher,
> >> > sorry for the delya of this answer but I have been travelling around
> >> > quite a lot lately.
> >> >
> >> > The GeoTiffWriter is able to encode custom projections, using (almost)
> >> > any CoordinateReferenceSystem you are using.
> >> >
> >> > Could you please provide an isolated test case to show where you are
> >> > encountering problems?
> >> >
> >> > Simone.
> >> >
> >> > On 11/1/06, Christopher Hammack <[EMAIL PROTECTED]> wrote:
> >> >> I am using the 2.3M0 binary build, and have been unable to write a
> >> >> GeoTIFF
> >> >> that does not have an EPSG code associated with it.
> >> >>
> >> >> For Example: Construct a grid coverage using EPSG:3033, use
> >> >> GeoTIFFReader
> >> >> to open it, and it works fine.
> >> >>
> >> >> Take the EPSG3033 WKT from the epsg.properties file, remove the EPSG
> >> >> code
> >> >> off the end and construct the CRS by using CRS.parse(...); Open the
> >> >> resulting GeoTIFF using GeoTIFFReader and the following happens:
> >> >>
> >> >> java.lang.NullPointerException
> >> >> at
> >> >> org.geotools.gce.geotiff.GeoTiffException.getMessage(GeoTiffException.java:202)
> >> >> at
> >> >> org.geotools.data.DataSourceException.<init>(DataSourceException.java:47)
> >> >> at
> >> >> org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:211)
> >> >> at
> >> >> org.geotools.gce.geotiff.GeoTiffFormat.getReader(GeoTiffFormat.java:194)
> >> >>
> >> >>
> >> >> Is the GeoTIFF writer designed in such a way that it can only encode
> >> >> EPSG
> >> >> codes in, rather than custom projections?
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> -------------------------------------------------------------------------
> >> >> Using Tomcat but need to do more? Need to support web services,
> >> >> security?
> >> >> Get stuff done quickly with pre-integrated technology to make your
> >> job
> >> >> easier
> >> >> Download IBM WebSphere Application Server v.1.0.1 based on Apache
> >> >> Geronimo
> >> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> >> >> _______________________________________________
> >> >> Geotools-gt2-users mailing list
> >> >> [email protected]
> >> >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> >> >>
> >> >
> >> >
> >> > --
> >> > -------------------------------------------------------
> >> > Eng. Simone Giannecchini
> >> > President /CEO GeoSolutions
> >> >
> >> > http://www.geo-solutions.it
> >> >
> >> > -------------------------------------------------------
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > --
> > -------------------------------------------------------
> > Eng. Simone Giannecchini
> > President /CEO GeoSolutions
> >
> > http://www.geo-solutions.it
> >
> > -------------------------------------------------------
> >
> >
>
>
>
--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions
http://www.geo-solutions.it
-------------------------------------------------------
--
-------------------------------------------------------
Eng. Simone Giannecchini
President /CEO GeoSolutions
http://www.geo-solutions.it
-------------------------------------------------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users