Select to view content in your preferred language

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

686
0
02-08-2017 10:50 PM
liuyunfeiliu
Deactivated User
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?

Tags (1)
0 Kudos
0 Replies