I'm trying to get Michael's code to run in a project set up as below... It's
not finding the org.geotools.gce.geotiff.GeoTiffReader package and thus
having a problem with GeoTiffReader in the code. I figure it is just a
dependency or something that is missing...?
==========================================================

pom.xml File:
-------------------------------------------

<project
    xmlns="http://maven.apache.org/POM/4.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.geotools</groupId>
    <artifactId>tutorial</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>tutorial</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <geotools.version>8.0-M0</geotools.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-shapefile</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>${geotools.version}</version>
        </dependency>
        <dependency>
           <groupId>org.geotools</groupId>
           <artifactId>gt-epsg-hsql</artifactId>
           <version>${geotools.version}</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net repository</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
        <repository>
            <id>osgeo</id>
            <name>Open Source Geospatial Foundation Repository</name>
            <url>http://download.osgeo.org/webdav/geotools/</url>
        </repository>
    </repositories>
</project>

===============================================

AsterDEM.java File:
-------------------------------------------------------------

package org.geotools.asterdem;

import java.awt.geom.Point2D;
import java.io.File;
import org.geotools.coverage.grid.GridCoordinates2D;
import org.geotools.coverage.grid.GridCoverage2D;
import org.geotools.gce.geotiff.GeoTiffReader;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.geometry.Envelope2D;
import org.geotools.swing.data.JFileDataStoreChooser;
import org.opengis.coverage.grid.GridEnvelope;
import org.opengis.geometry.DirectPosition;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform2D;


public class AsterDEM {
    public static void main(String[] args) throws Exception {

        File file = new
File("C:\\Pieter\\Development\\ASTGTM_S11E021_dem.tif");
        
        GeoTiffReader reader = new GeoTiffReader(file);
        GridCoverage2D cov = (GridCoverage2D) reader.read(null);
        
        GridEnvelope gridBounds = cov.getGridGeometry().getGridRange();
        System.out.println("grid bounds: " + gridBounds);
        
        Envelope2D worldBounds = cov.getEnvelope2D();
        System.out.println("world bounds: " + worldBounds);


        int numBands = cov.getNumSampleDimensions();
        System.out.println("num bands: " + numBands);
        
        CoordinateReferenceSystem crs = cov.getCoordinateReferenceSystem();
        
        // get the value of the centre location as an example
        double[] values = new double[numBands];
        double lon = worldBounds.getCenterX();
        double lat = worldBounds.getCenterY();
        DirectPosition dp = new DirectPosition2D(crs, lon, lat);
        cov.evaluate(dp, values);
        
        System.out.println("value at " + dp + " is " + values[0]);
    }
}

================================================

Project Build Output and Exceptions:
--------------------------------------------------------------

[compiler:compile]
Compiling 2 source files to C:\Pieter\Development\GeoTools
AsterDEM\AsterDEM\target\classes
-------------------------------------------------------------
COMPILATION ERROR : 
-------------------------------------------------------------
org/geotools/asterdem/AsterDEM.java:[7,31] package org.geotools.gce.geotiff
does not exist
org/geotools/asterdem/AsterDEM.java:[22,8] cannot find symbol
symbol  : class GeoTiffReader
location: class org.geotools.asterdem.AsterDEM
org/geotools/asterdem/AsterDEM.java:[22,35] cannot find symbol
symbol  : class GeoTiffReader
location: class org.geotools.asterdem.AsterDEM
3 errors 
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.312s
Finished at: Tue Jun 21 09:55:38 CAT 2011
Final Memory: 8M/19M
------------------------------------------------------------------------
Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project tutorial: Compilation failure: Compilation
failure:
\Pieter\Development\GeoTools
AsterDEM\AsterDEM\src\main\java\org\geotools\asterdem\AsterDEM.java:[7,31]
package org.geotools.gce.geotiff does not exist
\Pieter\Development\GeoTools
AsterDEM\AsterDEM\src\main\java\org\geotools\asterdem\AsterDEM.java:[22,8]
cannot find symbol
symbol  : class GeoTiffReader
location: class org.geotools.asterdem.AsterDEM
\Pieter\Development\GeoTools
AsterDEM\AsterDEM\src\main\java\org\geotools\asterdem\AsterDEM.java:[22,35]
cannot find symbol
symbol  : class GeoTiffReader
location: class org.geotools.asterdem.AsterDEM
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read
the following articles:
[Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Reading-ASTER-DEM-Data-tp3728702p6499017.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to