AnsweredAssumed Answered

String rasterPath = Environment.getExternalStorageDirectory().getPath() + "/raster/SM0803.tif";         FileRasterSource rasterSource=null;         try {             rasterSource = new FileRasterSource(rasterPath);             //rasterSource.project(mMapV

Question asked by liuyunfei0321 on Feb 8, 2017
String rasterPath = Environment.getExternalStorageDirectory().getPath() + "/raster/SM0803.tif";
        FileRasterSource rasterSource=null;
        try {
            rasterSource = new FileRasterSource(rasterPath);
            //rasterSource.project(mMapView.getSpatialReference());


//            StretchParameters stretchParams = new StretchParameters.MinMaxStretchParameters();
//            stretchParams.setGamma(2.0f);
//
//            StretchRenderer renderer = new StretchRenderer();
//            renderer.setStretchParameters(stretchParams);
//            rasterLayer.setRenderer(renderer);
            RasterLayer rasterLayer = new RasterLayer(rasterSource);
            Envelope env = rasterLayer.getFullExtent();
            double xmax=env.getXMax();
            double xmin = env.getXMin();
            double ymax = env.getYMax();
            double ymin = env.getYMin();

            mMapView.addLayer(rasterLayer);
            Log.d(TAG, rasterSource.getFormat());
            Log.d(TAG, String.valueOf(xmax)+","+String.valueOf(xmin)+","+String.valueOf(ymax)+","+String.valueOf(ymin));

        } catch (IllegalArgumentException ie) {
            Log.d(TAG, "null or empty path");
        } catch (FileNotFoundException fe) {
            Log.d(TAG, "raster file doesn't exist");
        } catch (RuntimeException re) {
            Log.d(TAG, "raster file can't be opened");
        }

rasterlayer cannot show! why?

Outcomes