Beispiel #1
0
        private async void Initialize()
        {
            try
            {
                // Set the altitude slider min/max and initial value (minimum is always 0 - do
                // not set _Altitude_Slider.Min = 0)
                _Slider_Altitude.Max      = 90;
                _Slider_Altitude.Progress = 45;

                // Set the azimuth slider min/max and initial value (minimum is always 0 - do
                // not set _AZimuth_Slider.Min = 0)
                _Slider_Azimuth.Max      = 360;
                _Slider_Azimuth.Progress = 180;

                // Load the raster file using a path on disk
                Raster myRasterImagery = new Raster(GetRasterPath_Imagery());

                // Create the raster layer from the raster
                RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery);

                // Create a new map using the raster layer as the base map
                Map myMap = new Map(new Basemap(myRasterLayerImagery));

                // Wait for the layer to load - this enabled being able to obtain the extent information
                // of the raster layer
                await myRasterLayerImagery.LoadAsync();

                // Create a new EnvelopeBuilder from the full extent of the raster layer
                EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent);

                // Zoom in the extent just a bit so that raster layer encompasses the entire viewable
                // area of the map
                myEnvelopBuilder.Expand(0.75);

                // Set the viewpoint of the map to the EnvelopeBuilder's extent
                myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent);

                // Add map to the map view
                _myMapView.Map = myMap;

                // Wait for the map to load
                await myMap.LoadAsync();

                // Enable the 'Update Renderer' button now that the map has loaded
                _Button_UpdateRenderer.Enabled = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Beispiel #2
0
        private async void Initialize()
        {
            // Set the altitude slider min/max and initial value.
            _altitudeSlider.MinValue = 0;
            _altitudeSlider.MaxValue = 90;
            _altitudeSlider.Value    = 45;

            // Set the azimuth slider min/max and initial value.
            _azimuthSlider.MinValue = 0;
            _azimuthSlider.MaxValue = 360;
            _azimuthSlider.Value    = 180;

            // Load the raster file using a path on disk.
            Raster rasterImagery = new Raster(DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif"));

            // Create the raster layer from the raster.
            RasterLayer rasterLayerImagery = new RasterLayer(rasterImagery);

            // Create a new map using the raster layer as the base map.
            Map map = new Map(new Basemap(rasterLayerImagery));

            try
            {
                // Wait for the layer to load - this enabled being able to obtain the raster layer's extent.
                await rasterLayerImagery.LoadAsync();

                // Create a new EnvelopeBuilder from the full extent of the raster layer.
                EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(rasterLayerImagery.FullExtent);

                // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map.
                envelopeBuilder.Expand(0.75);

                // Set the viewpoint of the map to the EnvelopeBuilder's extent.
                map.InitialViewpoint = new Viewpoint(envelopeBuilder.ToGeometry().Extent);

                // Add map to the map view.
                _myMapView.Map = map;

                // Wait for the map to load.
                await map.LoadAsync();

                // Enable the 'Update Renderer' button now that the map has loaded.
                _updateRendererButton.Enabled = true;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private async void Initialize()
        {
            // Update the preset color ramp type options and select the first one.
            ColorRamps.ItemsSource   = Enum.GetNames(typeof(PresetColorRampType));
            ColorRamps.SelectedIndex = 0;

            // Update the slope options and select the first one.
            SlopeTypes.ItemsSource   = Enum.GetNames(typeof(SlopeType));
            SlopeTypes.SelectedIndex = 0;

            // Load the raster file using a path on disk.
            Raster myRasterImagery = new Raster(GetRasterPath_Imagery());

            // Create the raster layer from the raster.
            RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery);

            // Create a new map using the raster layer as the base map.
            Map myMap = new Map(new Basemap(myRasterLayerImagery));

            try
            {
                // Wait for the layer to load - this enabled being able to obtain the extent information
                // of the raster layer.
                await myRasterLayerImagery.LoadAsync();

                // Create a new EnvelopeBuilder from the full extent of the raster layer.
                EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent);

                // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map.
                myEnvelopBuilder.Expand(0.75);

                // Set the viewpoint of the map to the EnvelopeBuilder's extent.
                myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent);

                // Add map to the map view.
                MyMapView.Map = myMap;

                // Wait for the map to load.
                await myMap.LoadAsync();

                // Enable the 'Update Renderer' button now that the map has loaded.
                UpdateRenderer.IsEnabled = true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
        private async Task Initialize()
        {
            // Create a raster layer using an image service.
            _imageServiceRaster = new ImageServiceRaster(new Uri("https://sampleserver7.arcgisonline.com/server/rest/services/amberg_germany/ImageServer"));
            RasterLayer rasterLayer = new RasterLayer(_imageServiceRaster);
            await rasterLayer.LoadAsync();

            // Create a map with the raster layer.
            MyMapView.Map = new Map(BasemapStyle.ArcGISTopographic);
            MyMapView.Map.OperationalLayers.Add(rasterLayer);
            await MyMapView.SetViewpointAsync(new Viewpoint(rasterLayer.FullExtent));

            // Populate the combo box.
            MosaicRulesBox.ItemsSource   = _mosaicRules.Keys;
            MosaicRulesBox.SelectedIndex = 0;
        }
Beispiel #5
0
        private async Task Initialize()
        {
            // Create a raster layer using an image service.
            _imageServiceRaster = new ImageServiceRaster(new Uri("https://sampleserver7.arcgisonline.com/server/rest/services/amberg_germany/ImageServer"));
            RasterLayer rasterLayer = new RasterLayer(_imageServiceRaster);
            await rasterLayer.LoadAsync();

            // Create a map with the raster layer.
            _myMapView.Map = new Map(BasemapStyle.ArcGISTopographic);
            _myMapView.Map.OperationalLayers.Add(rasterLayer);
            await _myMapView.SetViewpointAsync(new Viewpoint(rasterLayer.FullExtent));

            // Populate the combo box.
            _imageServiceRaster.MosaicRule = _mosaicRules["None"];
            _rulePickerButton.Text         = "Rule: None";
        }
Beispiel #6
0
        private async void Initialize()
        {
            // Create a map with a streets basemap
            Map map = new Map(Basemap.CreateStreets());

            // Get the file name for the local raster dataset
            string filepath = GetRasterPath();

            // Load the raster file
            Raster rasterFile = new Raster(filepath);

            try
            {
                // Create and load a new raster layer to show the image
                _rasterLayer = new RasterLayer(rasterFile);
                await _rasterLayer.LoadAsync();

                // Enable the apply renderer button when the layer loads.
                ApplyHillshadeButton.IsEnabled = true;

                // Create a viewpoint with the raster's full extent
                Viewpoint fullRasterExtent = new Viewpoint(_rasterLayer.FullExtent);

                // Set the initial viewpoint for the map
                map.InitialViewpoint = fullRasterExtent;

                // Add the layer to the map
                map.OperationalLayers.Add(_rasterLayer);

                // Add the map to the map view
                MyMapView.Map = map;

                // Add slope type values to the dictionary and picker
                foreach (object slope in Enum.GetValues(typeof(SlopeType)))
                {
                    _slopeTypeValues.Add(slope.ToString(), (SlopeType)slope);
                    SlopeTypePicker.Items.Add(slope.ToString());
                }

                // Select the "Scaled" slope type enum
                SlopeTypePicker.SelectedIndex = 2;
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
        private async void Initialize()
        {
            // Create a map with a streets basemap
            Map map = new Map(BasemapStyle.ArcGISStreets);

            // Get the file name for the local raster dataset
            string filepath = GetRasterPath();

            // Load the raster file
            Raster rasterFile = new Raster(filepath);

            try
            {
                // Create and load a new raster layer to show the image
                _rasterLayer = new RasterLayer(rasterFile);
                await _rasterLayer.LoadAsync();

                // Enable the apply renderer button when the layer loads.
                ApplyHillshadeButton.IsEnabled = true;

                // Create a viewpoint with the raster's full extent
                Viewpoint fullRasterExtent = new Viewpoint(_rasterLayer.FullExtent);

                // Set the initial viewpoint for the map
                map.InitialViewpoint = fullRasterExtent;

                // Add the layer to the map
                map.OperationalLayers.Add(_rasterLayer);

                // Add the map to the map view
                MyMapView.Map = map;

                // Add slope type values to the combo box
                foreach (object slope in Enum.GetValues(typeof(SlopeType)))
                {
                    SlopeTypeCombo.Items.Add(slope);
                }

                // Select the "Scaled" slope type enum
                SlopeTypeCombo.SelectedValue = SlopeType.Scaled;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
        private async void Initialize()
        {
            // Set the altitude slider min/max and initial value
            _Altitude_Slider.MinValue = 0;
            _Altitude_Slider.MaxValue = 90;
            _Altitude_Slider.Value    = 45;

            // Set the azimuth slider min/max and initial value
            _Azimuth_Slider.MinValue = 0;
            _Azimuth_Slider.MaxValue = 360;
            _Azimuth_Slider.Value    = 180;

            // Load the raster file using a path on disk
            Raster myRasterImagery = new Raster(GetRasterPath_Imagery());

            // Create the raster layer from the raster
            RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery);

            // Create a new map using the raster layer as the base map
            Map myMap = new Map(new Basemap(myRasterLayerImagery));

            // Wait for the layer to load - this enabled being able to obtain the extent information
            // of the raster layer
            await myRasterLayerImagery.LoadAsync();

            // Create a new EnvelopeBuilder from the full extent of the raster layer
            EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent);

            // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map
            myEnvelopBuilder.Expand(0.75);

            // Set the viewpoint of the map to the EnvelopeBuilder's extent
            myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent);

            // Add map to the map view
            _myMapView.Map = myMap;

            // Wait for the map to load
            await myMap.LoadAsync();

            // Enable the 'Update Renderer' button now that the map has loaded
            _UpdateRenderer.Enabled = true;
        }
Beispiel #9
0
        private async void Initialize()
        {
            // Define a new map with Wgs84 Spatial Reference.
            var map = new Map(BasemapType.Oceans, latitude: -34.1, longitude: 18.6, levelOfDetail: 9);

            // Get the file name for the raster.
            string filepath = DataManager.GetDataFolder("b5f977c78ec74b3a8857ca86d1d9b318", "SA_EVI_8Day_03May20.tif");

            // Load the raster file.
            var raster = new Raster(filepath);

            // Initialize the raster layer.
            _rasterLayer = new RasterLayer(raster);

            // Add the raster layer to the map.
            map.OperationalLayers.Add(_rasterLayer);

            // Add map to the map view.
            MyMapView.Map = map;

            try
            {
                // Wait for the layer to load.
                await _rasterLayer.LoadAsync();

                // Set the viewpoint.
                await MyMapView.SetViewpointGeometryAsync(_rasterLayer.FullExtent);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }

            // Listen for mouse movement to start the identify operation.
            MyMapView.MouseMove += MouseMoved;

            // Disable magnifier.
            MyMapView.InteractionOptions = new MapViewInteractionOptions
            {
                IsMagnifierEnabled = false
            };
        }
        private async void showBtn_Click(object sender, RoutedEventArgs e)
        {
            // 读取栅格文件
            Raster myRasterFile = new Raster(rasterResultPath);
            // 创建栅格图层
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // 显示到窗口
            MainWindow.myMapLayersList.Add(myRasterLayer);
            // 加入到业务图层列表
            myMapView.Map.OperationalLayers.Add(myRasterLayer);
            // 等待图层加载完成
            await myRasterLayer.LoadAsync();

            // 设置四至,缩放至图层
            await myMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);

            // 加入到checkbox列表
            ((TableOfContent)w.FindName("myTableOfContent")).addLayersList(System.IO.Path.GetFileName(rasterResultPath));
        }
        private async void Initialize()
        {
            // Add an imagery basemap.
            Map map = new Map(Basemap.CreateImagery());

            // Load the raster file.
            Raster rasterFile = new Raster(_rasterPath);

            // Create the layer.
            RasterLayer rasterLayer = new RasterLayer(rasterFile);

            // Create a color map where values 0-149 are red and 150-249 are yellow.
            IEnumerable <Color> colors = new int[250]
                                         .Select((c, i) => i < 150 ? Color.Red : Color.Yellow);

            // Create a colormap renderer.
            ColormapRenderer colormapRenderer = new ColormapRenderer(colors);

            // Set the colormap renderer on the raster layer.
            rasterLayer.Renderer = colormapRenderer;

            // Add the layer to the map.
            map.OperationalLayers.Add(rasterLayer);

            // Add map to the mapview.
            MyMapView.Map = map;

            try
            {
                // Wait for the layer to load.
                await rasterLayer.LoadAsync();

                // Set the viewpoint.
                await MyMapView.SetViewpointGeometryAsync(rasterLayer.FullExtent, 15);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                MessageBox.Show(e.Message, "Error");
            }
        }
        private async void Initialize()
        {
            // Create a simple string array of the human-readable stretch renderer names from the ObservableCollection
            string[] myStringArray_RendererTypes = { "Min Max", "Percent Clip", "Standard Deviation" };

            // Create an ArrayAdapter from the simple string array
            ArrayAdapter myArrayAdapter_LayerNamesInTheMap = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myStringArray_RendererTypes);

            // Display the human-readable stretch renderer names to be displayed a ListView
            _RendererTypes.Adapter = myArrayAdapter_LayerNamesInTheMap;

            // Add an imagery basemap
            _myMapView.Map = new Map(Basemap.CreateImagery());

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // Add the layer to the map
            _myMapView.Map.OperationalLayers.Add(myRasterLayer);

            try
            {
                // Wait for the layer to load
                await myRasterLayer.LoadAsync();

                // Set the viewpoint
                await _myMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
        private async void Initialize()
        {
            // Load the raster file using a path on disk.
            Raster rasterImagery = new Raster(DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif"));

            // Create the raster layer from the raster.
            RasterLayer rasterLayerImagery = new RasterLayer(rasterImagery);

            // Create a new map using the raster layer as the base map.
            Map map = new Map(new Basemap(rasterLayerImagery));

            try
            {
                // Wait for the layer to load - this enabled being able to obtain the raster layer's extent.
                await rasterLayerImagery.LoadAsync();

                // Create a new EnvelopeBuilder from the full extent of the raster layer.
                EnvelopeBuilder envelopeBuilder = new EnvelopeBuilder(rasterLayerImagery.FullExtent);

                // Configure the settings view.
                _settingsVC = new BlendSettingsController(map);

                // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map.
                envelopeBuilder.Expand(0.75);

                // Set the viewpoint of the map to the EnvelopeBuilder's extent.
                map.InitialViewpoint = new Viewpoint(envelopeBuilder.ToGeometry().Extent);

                // Add map to the map view.
                _myMapView.Map = map;

                // Wait for the map to load.
                await map.LoadAsync();
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private async void Initialize()
        {
            // Initialize the GUI controls appearance
            ObservableCollection <string> myObservableCollection_RendererTypes = new ObservableCollection <string>();

            myObservableCollection_RendererTypes.Add("Min Max");
            myObservableCollection_RendererTypes.Add("Percent Clip");
            myObservableCollection_RendererTypes.Add("Standard Deviation");
            RendererTypes.ItemsSource  = myObservableCollection_RendererTypes;
            RendererTypes.SelectedItem = "Min Max";

            // Add an imagery basemap
            MyMapView.Map = new Map(BasemapStyle.ArcGISImageryStandard);

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // Add the layer to the map
            MyMapView.Map.OperationalLayers.Add(myRasterLayer);

            try
            {
                // Wait for the layer to load
                await myRasterLayer.LoadAsync();

                // Set the viewpoint
                await MyMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }
Beispiel #15
0
        private async void Initialize()
        {
            // Create a simple string array of the human-readable stretch renderer names from the ObservableCollection
            string[] myStringArray_RendererTypes = { "Min Max", "Percent Clip", "Standard Deviation" };

            // Create an ArrayAdapter from the simple string array
            ArrayAdapter myArrayAdapter_LayerNamesInTheMap = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myStringArray_RendererTypes);

            // Display the human-readable stretch renderer names to be displayed a ListView
            _RendererTypes.Adapter = myArrayAdapter_LayerNamesInTheMap;

            // Add an imagery basemap
            Map myMap = new Map(Basemap.CreateImagery());

            // Wait for the map to load
            await myMap.LoadAsync();

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // Add the layer to the map
            myMap.OperationalLayers.Add(myRasterLayer);

            // Wait for the layer to load
            await myRasterLayer.LoadAsync();

            // Set the viewpoint
            myMap.InitialViewpoint = new Viewpoint(myRasterLayer.FullExtent);

            // Add map to the mapview
            _myMapView.Map = myMap;
        }
        private async void Initialize()
        {
            // Initialize the GUI controls appearance
            ObservableCollection <string> myObservableCollection_RendererTypes = new ObservableCollection <string>();

            myObservableCollection_RendererTypes.Add("Min Max");
            myObservableCollection_RendererTypes.Add("Percent Clip");
            myObservableCollection_RendererTypes.Add("Standard Deviation");
            RendererTypes.ItemsSource  = myObservableCollection_RendererTypes;
            RendererTypes.SelectedItem = "Min Max";

            // Add an imagery basemap
            Map myMap = new Map(Basemap.CreateImagery());

            // Wait for the map to load
            await myMap.LoadAsync();

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // Add the layer to the map
            myMap.OperationalLayers.Add(myRasterLayer);

            // Wait for the layer to load
            await myRasterLayer.LoadAsync();

            // Set the viewpoint
            myMap.InitialViewpoint = new Viewpoint(myRasterLayer.FullExtent);

            // Add map to the mapview
            MyMapView.Map = myMap;
        }
Beispiel #17
0
        private async void Initialize()
        {
            // Get the file name
            String filepath = await GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // Load the layer
            await myRasterLayer.LoadAsync();

            // Add the layer to the map
            _myMapView.Map.OperationalLayers.Add(myRasterLayer);

            // Get the raster's extent in a viewpoint
            Viewpoint myFullRasterExtent = new Viewpoint(myRasterLayer.FullExtent);

            // Zoom to the extent
            _myMapView.Map.InitialViewpoint = myFullRasterExtent;
        }
        private async void Initialize()
        {
            //Add the geotif to the map. This is the geotif we ultimatly want to convert to a tile package
            Raster myRaster = new Raster(@"C:\Temp\test.tif");
            //await myRaster.LoadAsync();
            RasterLayer newRasterLayer = new RasterLayer(myRaster);

            // Add the raster layer to the maps layer collection.

            myMap.OperationalLayers.Add(newRasterLayer);
            // Assign the map to the map view.
            MyMapView.Map = myMap;
            try
            {
                await newRasterLayer.LoadAsync();

                await MyMapView.SetViewpointGeometryAsync(newRasterLayer.FullExtent);
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.Message);
            }
        }
        private async void Initialize()
        {
            // Create a new map.
            _myMapView.Map = new Map(BasemapStyle.ArcGISLightGray);

            // Get the GeoPackage path.
            string geoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");

            try
            {
                // Open the GeoPackage.
                GeoPackage geoPackage = await GeoPackage.OpenAsync(geoPackagePath);

                // Read the raster images and get the first one.
                Raster gpkgRaster = geoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package.
                if (gpkgRaster == null)
                {
                    return;
                }

                // Create a layer to show the raster.
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint.
                await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology).
                _myMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map myMap = new Map(Basemap.CreateStreets());

            // Get the file name for the local raster dataset.
            string filepath = GetRasterPath();

            // Load the raster file
            Raster rasterFile = new Raster(filepath);

            try
            {
                // Create and load a new raster layer to show the image.
                _rasterLayer = new RasterLayer(rasterFile);
                await _rasterLayer.LoadAsync();

                // Once the layer is loaded, enable the button to apply a new renderer.
                _applyRendererButton.Enabled = true;

                // Create a viewpoint with the raster's full extent.
                Viewpoint fullRasterExtent = new Viewpoint(_rasterLayer.FullExtent);

                // Set the initial viewpoint for the map.
                myMap.InitialViewpoint = fullRasterExtent;

                // Add the layer to the map.
                myMap.OperationalLayers.Add(_rasterLayer);

                // Add the map to the map view.
                _myMapView.Map = myMap;
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
Beispiel #21
0
        private async void Initialize()
        {
            // Create a new map
            _myMapView.Map = new Map(BasemapStyle.ArcGISLightGray);

            // Get the full path
            string geoPackagePath = GetGeoPackagePath();

            try
            {
                // Open the GeoPackage
                GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath);

                // Read the raster images and get the first one
                Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package
                if (gpkgRaster == null)
                {
                    return;
                }

                // Create a layer to show the raster
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint
                await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology)
                _myMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
        private async void Initialize()
        {
            // Create a new map
            MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas());

            // Get the full path
            string geoPackagePath = GetGeoPackagePath();

            try
            {
                // Open the GeoPackage
                GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath);

                // Read the raster images and get the first one
                Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package
                if (gpkgRaster == null)
                {
                    return;
                }

                // Create a layer to show the raster
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint
                await MyMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology)
                MyMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                await((Page)Parent).DisplayAlert("Error", e.ToString(), "OK");
            }
        }
Beispiel #23
0
        private async void Initialize()
        {
            // Initialize the GUI controls appearance
            RendererTypes.Items.Add("Min Max");
            RendererTypes.Items.Add("Percent Clip");
            RendererTypes.Items.Add("Standard Deviation");
            RendererTypes.SelectedIndex = 0;

            // Add an imagery basemap
            MyMapView.Map = new Map(Basemap.CreateImagery());

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

            // Add the layer to the map
            MyMapView.Map.OperationalLayers.Add(myRasterLayer);

            try
            {
                // Wait for the layer to load
                await myRasterLayer.LoadAsync();

                // Set the viewpoint
                await MyMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }
        }
        private async void Initialize()
        {
            // Define a new map with Wgs84 Spatial Reference.
            var map = new Map(BasemapType.Oceans, latitude: -34.1, longitude: 18.6, levelOfDetail: 9);

            // Get the file name for the raster.
            string filepath = DataManager.GetDataFolder("b5f977c78ec74b3a8857ca86d1d9b318", "SA_EVI_8Day_03May20.tif");

            // Load the raster file.
            var raster = new Raster(filepath);

            // Initialize the raster layer.
            _rasterLayer = new RasterLayer(raster);

            // Add the raster layer to the map.
            map.OperationalLayers.Add(_rasterLayer);

            // Add map to the map view.
            MyMapView.Map = map;

            try
            {
                // Wait for the layer to load.
                await _rasterLayer.LoadAsync();

                // Set the viewpoint.
                await MyMapView.SetViewpointGeometryAsync(_rasterLayer.FullExtent);
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert(ex.GetType().Name, ex.Message, "OK");
            }

            // Listen for mouse movement to start the identify operation.
            MyMapView.GeoViewTapped += MapTapped;
        }
Beispiel #25
0
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map myMap = new Map(Basemap.CreateStreets());

            // Get the file name for the local raster dataset.
            string filepath = GetRasterPath();

            // Load the raster file
            Raster rasterFile = new Raster(filepath);

            try
            {
                // Create a new raster layer to show the image.
                _rasterLayer = new RasterLayer(rasterFile);
                await _rasterLayer.LoadAsync();

                // Set the initial viewpoint for the map to the raster's full extent.
                myMap.InitialViewpoint = new Viewpoint(_rasterLayer.FullExtent);

                // Add the layer to the map.
                myMap.OperationalLayers.Add(_rasterLayer);

                // Add the map to the map view.
                _myMapView.Map = myMap;

                // Create the settings view controllers.
                _minMaxController      = new MinMaxSettingsController(_rasterLayer);
                _percentClipController = new PercentClipSettingsController(_rasterLayer);
                _stdDevController      = new StandardDeviationSettingsController(_rasterLayer);
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
        private async void Initialize()
        {
            // Create a new map centered on Aurora Colorado
            MyMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.8319, 11);

            // Get the full path to the GeoPackage on the device
            string myGeoPackagePath = GetGeoPackagePath();

            try
            {
                // Open the GeoPackage
                GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath);

                // Get the read only list of GeoPackageRasters from the GeoPackage
                IReadOnlyList <GeoPackageRaster> myReadOnlyListOfGeoPackageRasters = myGeoPackage.GeoPackageRasters;

                // Loop through each GeoPackageRaster
                int idx = 0;
                foreach (GeoPackageRaster oneGeoPackageRaster in myReadOnlyListOfGeoPackageRasters)
                {
                    // Create a RasterLayer from the GeoPackageRaster
                    RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster)
                    {
                        // Set the opacity on the RasterLayer to partially visible
                        Opacity = 0.55
                    };

                    // Load the RasterLayer - that way we can get to it's properties
                    await myRasterLayer.LoadAsync();

                    // Create a string variable to hold the human-readable name of the RasterLayer for display
                    // in the ListBox and the HybridDictonary - it will initially be an empty string
                    string myRasterLayerName = "";

                    if (myRasterLayer.Name != "")
                    {
                        // We have a good human-readable name for the RasterLayer that came from
                        // the RasterLayer.Name property
                        myRasterLayerName = myRasterLayer.Name;
                    }
                    else if (oneGeoPackageRaster.Path.Split('/').Last() != "")
                    {
                        // We did not get a good human-readable name from the RasterLayer from the .Name
                        // property, get the good human-readable name from the GeoPackageRaster.Path instead
                        myRasterLayerName = oneGeoPackageRaster.Path.Split('\\').Last();
                    }

                    // Append the 'type of layer' to the myRasterLayerName string to display in the
                    // ListBox and as the key for the HybridDictonary
                    myRasterLayerName = myRasterLayerName + " - RasterLayer " + ++idx;

                    // Add the name of the RasterLayer and the RasterLayer itself into the HybridDictionary
                    _myHybridDictionary_Layers.Add(myRasterLayerName, myRasterLayer);

                    // Add the name of the RasterLayer to the ListBox of layers not in map
                    LayersNotInTheMapList.Items.Add(myRasterLayerName);
                }

                // Get the read only list of GeoPackageFeatureTabless from the GeoPackage
                IReadOnlyList <GeoPackageFeatureTable> myReadOnlyListOfGeoPackageFeatureTables = myGeoPackage.GeoPackageFeatureTables;

                // Loop through each GeoPackageFeatureTable
                foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myReadOnlyListOfGeoPackageFeatureTables)
                {
                    // Create a FeatureLayer from the GeoPackageFeatureLayer
                    FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable);

                    // Load the FeatureLayer - that way we can get to it's properties
                    await myFeatureLayer.LoadAsync();

                    // Create a string variable to hold the human-readable name of the FeatureLayer for
                    // display in the ListBox and the HybridDictonary
                    string myFeatureLayerName = myFeatureLayer.Name;

                    // Append the 'type of layer' to the myFeatureLayerName string to display in the
                    // ListBox and as the key for the HybridDictonary
                    myFeatureLayerName = myFeatureLayerName + " - FeatureLayer";

                    // Add the name of the FeatureLayer and the FeatureLayer itself into the HybridDictionary
                    _myHybridDictionary_Layers.Add(myFeatureLayerName, myFeatureLayer);

                    // Add the name of the FeatureLayer to the ListBox of layers not in map
                    LayersNotInTheMapList.Items.Add(myFeatureLayerName);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
Beispiel #27
0
        private async void Initialize()
        {
            // Create a new map centered on Aurora Colorado
            MyMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.8319, 11);

            // Get the full path to the GeoPackage on the device
            string myGeoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");

            // Open the GeoPackage
            GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath);

            // Loop through each GeoPackageRaster
            foreach (GeoPackageRaster oneGeoPackageRaster in myGeoPackage.GeoPackageRasters)
            {
                // Create a RasterLayer from the GeoPackageRaster
                RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster)
                {
                    // Set the opacity on the RasterLayer to partially visible
                    Opacity = 0.55
                };

                // Load the RasterLayer - that way we can get to it's properties
                await myRasterLayer.LoadAsync();

                // Create a string variable to hold the name of the RasterLayer for display
                // in the ListBox and the Dictionary - it will initially be an empty string
                string myRasterLayerName = "";

                if (myRasterLayer.Name != "")
                {
                    // We have a good name for the RasterLayer that came from
                    // the RasterLayer.Name property
                    myRasterLayerName = myRasterLayer.Name;
                }
                else if (oneGeoPackageRaster.Path.Split('/').Last() != "")
                {
                    // We did not get a good name from the RasterLayer from the .Name
                    // property, get the good name from the GeoPackageRaster.Path instead
                    myRasterLayerName = oneGeoPackageRaster.Path.Split('/').Last();
                }

                // Append the 'type of layer' to the myRasterLayerName string to display in the
                // ListBox and as the key for the Dictionary
                myRasterLayerName = myRasterLayerName + " - RasterLayer";

                // Add the name of the RasterLayer and the RasterLayer itself into the Dictionary
                _nameToLayerDictionary[myRasterLayerName] = myRasterLayer;

                // Add the name of the RasterLayer to the ListBox of layers not in map
                LayersNotInTheMap.Items.Add(myRasterLayerName);
            }

            // Loop through each GeoPackageFeatureTable
            foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myGeoPackage.GeoPackageFeatureTables)
            {
                // Create a FeatureLayer from the GeoPackageFeatureLayer
                FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable);

                // Load the FeatureLayer - that way we can get to it's properties
                await myFeatureLayer.LoadAsync();

                // Create a string variable to hold the human-readable name of the FeatureLayer for
                // display in the ListBox and the Dictionary
                string myFeatureLayerName = myFeatureLayer.Name;

                // Append the 'type of layer' to the myFeatureLayerName string to display in the
                // ListBox and as the key for the Dictionary
                myFeatureLayerName = myFeatureLayerName + " - FeatureLayer";

                // Add the name of the FeatureLayer and the FeatureLayer itself into the Dictionary
                _nameToLayerDictionary[myFeatureLayerName] = myFeatureLayer;

                // Add the name of the FeatureLayer to the ListBox of layers not in map
                LayersNotInTheMap.Items.Add(myFeatureLayerName);
            }
        }
        // Initialize creates the Map objects, assigns rasters, and creates bookmarks
        private async void Initialize()
        {
            // add imagery basemap to both scenes
            Scene BeforeMap = new Scene(Basemap.CreateImageryWithLabels());
            Scene AfterMap  = new Scene(Basemap.CreateImageryWithLabels());

            // wait for scenes to load
            await BeforeMap.LoadAsync();

            await AfterMap.LoadAsync();

            // Assigns Scene objects to View
            NaturalDisasterBefore.Scene = BeforeMap;
            NaturalDisasterAfter.Scene  = AfterMap;

            // List containing paths to each "before" raster
            string[] beforeimages;
            String   fpath = Path.Combine(Directory.GetCurrentDirectory(), "BeforeImages\\");

            beforeimages = Directory.GetFiles(fpath, "*", SearchOption.AllDirectories).Select(x => Path.GetFileName(x)).ToArray();

            // List containing paths to each "after" raster
            string[] afterimages;
            String   fpath2 = Path.Combine(Directory.GetCurrentDirectory(), "AfterImages\\");

            afterimages = Directory.GetFiles(fpath2, "*", SearchOption.AllDirectories).Select(x => Path.GetFileName(x)).ToArray();

            // Iterate through "before" raster list and add each one to the BeforeMap
            foreach (var item in beforeimages)
            {
                // specify filepath to raster location
                string filepath = Path.Combine(Directory.GetCurrentDirectory(), "BeforeImages\\" + item);

                // Load the raster file
                Raster myRasterFile = new Raster(filepath);

                // Create the layer
                RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

                // Add the layer and bookmark to the map
                BeforeMap.OperationalLayers.Add(myRasterLayer);

                // Wait for the layer to load
                await myRasterLayer.LoadAsync();

                //Creates an envelope for the current Raster
                var             rasterGeometry = myRasterLayer.FullExtent;
                EnvelopeBuilder newEnvelope    = new EnvelopeBuilder(rasterGeometry);
                newEnvelope.Expand(1.5);

                // Creates an envelope for comparison to bookmark location
                EnvelopeBuilder textEnvelope = new EnvelopeBuilder(rasterGeometry);
                textEnvelope.Expand(2.5);

                var xMax             = newEnvelope.XMax;
                var yMax             = newEnvelope.YMax;
                var xMin             = newEnvelope.XMin;
                var yMin             = newEnvelope.YMin;
                var spatialreference = newEnvelope.SpatialReference;

                // Converts newEnvelope to a geometry object that can be read as a Viewpoint
                Envelope rasterEnvelope = new Envelope(xMin, yMin, xMax, yMax, spatialreference);

                // Create Bookmark location and name for current raster
                // Raster needs spatial reference to load
                try
                {
                    if (rasterEnvelope.SpatialReference != null)
                    {
                        Viewpoint viewpoint = new Viewpoint(rasterEnvelope);
                        Bookmark  bookmark  = new Bookmark
                        {
                            Name      = Path.GetFileNameWithoutExtension(item),
                            Viewpoint = viewpoint
                        };
                        NaturalDisasterBefore.Scene.Bookmarks.Add(bookmark);
                        BookmarkChooser.Items.Add(bookmark);
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }

            // Iterate through "after" raster list and add each one to the AfterMap
            // Same as the one for the BeforeMap
            foreach (var item in afterimages)
            {
                // specify filepath to raster location
                string filepath = Path.Combine(Directory.GetCurrentDirectory(), "AfterImages\\" + item);

                // Load the raster file
                Raster myRasterFile = new Raster(filepath);

                // Create the layer
                RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

                // Add the layer and bookmark to the map
                AfterMap.OperationalLayers.Add(myRasterLayer);

                // Wait for the layer to load
                await myRasterLayer.LoadAsync();
            }
        }
        private async void Initialize()
        {
            // Create a map with a streets basemap.
            Map map = new Map(Basemap.CreateStreets());

            // Get the file name for the local raster dataset.
            string filepath = GetRasterPath();

            // Load the raster file
            Raster rasterFile = new Raster(filepath);

            // Create a new raster layer to show the image.
            _rasterLayer = new RasterLayer(rasterFile);

            try
            {
                // Once the layer is loaded, enable the button to apply a new renderer.
                await _rasterLayer.LoadAsync();

                ApplyRgbRendererButton.IsEnabled = true;

                // Create a viewpoint with the raster's full extent.
                Viewpoint fullRasterExtent = new Viewpoint(_rasterLayer.FullExtent);

                // Set the initial viewpoint for the map.
                map.InitialViewpoint = fullRasterExtent;

                // Add the layer to the map.
                map.OperationalLayers.Add(_rasterLayer);

                // Add the map to the map view.
                MyMapView.Map = map;

                // Add available stretch types to the combo box.
                StretchTypeComboBox.Items.Add("Min Max");
                StretchTypeComboBox.Items.Add("Percent Clip");
                StretchTypeComboBox.Items.Add("Standard Deviation");

                // Select "Min Max" as the stretch type.
                StretchTypeComboBox.SelectedIndex = 0;

                // Create a range of values from 0-255.
                List <int> minMaxValues = Enumerable.Range(0, 256).ToList();

                // Fill the min and max red combo boxes with the range and set default values.
                MinRedComboBox.ItemsSource   = minMaxValues;
                MinRedComboBox.SelectedValue = 0;
                MaxRedComboBox.ItemsSource   = minMaxValues;
                MaxRedComboBox.SelectedValue = 255;

                // Fill the min and max green combo boxes with the range and set default values.
                MinGreenComboBox.ItemsSource   = minMaxValues;
                MinGreenComboBox.SelectedValue = 0;
                MaxGreenComboBox.ItemsSource   = minMaxValues;
                MaxGreenComboBox.SelectedValue = 255;

                // Fill the min and max blue combo boxes with the range and set default values.
                MinBlueComboBox.ItemsSource   = minMaxValues;
                MinBlueComboBox.SelectedValue = 0;
                MaxBlueComboBox.ItemsSource   = minMaxValues;
                MaxBlueComboBox.SelectedValue = 255;

                // Fill the standard deviation factor combo box and set a default value.
                IEnumerable <int> wholeStdDevs = Enumerable.Range(1, 10);
                List <double>     halfStdDevs  = wholeStdDevs.Select(i => (double)i / 2).ToList();
                StdDeviationFactorComboBox.ItemsSource   = halfStdDevs;
                StdDeviationFactorComboBox.SelectedValue = 2.0;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }
        private async void Initialize()
        {
            // Get all the ColorRamp names from the PresetColorRampType Enumeration and put them
            // in an array of strings, then set the ComboBox.ItemSource to the array, and finally
            // select the first item in the ComboBox
            string[] myPresetColorRampTypes = System.Enum.GetNames(typeof(PresetColorRampType));
            ColorRamps.ItemsSource   = myPresetColorRampTypes;
            ColorRamps.SelectedIndex = 0;

            // Get all the SlopeType names from the SlopeType Enumeration and put them
            // in an array of strings, then set the ComboBox.ItemSource to the array, and finally
            // select the first item in the ComboBox
            string[] mySlopeTypes = System.Enum.GetNames(typeof(SlopeType));
            SlopeTypes.ItemsSource   = mySlopeTypes;
            SlopeTypes.SelectedIndex = 0;

            // Set the altitude slider min/max and initial value
            AltitudeSlider.Minimum = 0;
            AltitudeSlider.Maximum = 90;
            AltitudeSlider.Value   = 45;

            // Set the azimuth slider min/max and initial value
            AzimuthSlider.Minimum = 0;
            AzimuthSlider.Maximum = 360;
            AzimuthSlider.Value   = 180;

            // Load the raster file using a path on disk
            Raster myRasterImagery = new Raster(GetRasterPath_Imagery());

            // Create the raster layer from the raster
            RasterLayer myRasterLayerImagery = new RasterLayer(myRasterImagery);

            // Create a new map using the raster layer as the base map
            Map myMap = new Map(new Basemap(myRasterLayerImagery));

            try
            {
                // Wait for the layer to load - this enabled being able to obtain the extent information
                // of the raster layer
                await myRasterLayerImagery.LoadAsync();

                // Create a new EnvelopeBuilder from the full extent of the raster layer
                EnvelopeBuilder myEnvelopBuilder = new EnvelopeBuilder(myRasterLayerImagery.FullExtent);

                // Zoom in the extent just a bit so that raster layer encompasses the entire viewable area of the map
                myEnvelopBuilder.Expand(0.75);

                // Set the viewpoint of the map to the EnvelopeBuilder's extent
                myMap.InitialViewpoint = new Viewpoint(myEnvelopBuilder.ToGeometry().Extent);

                // Add map to the map view
                MyMapView.Map = myMap;

                // Wait for the map to load
                await myMap.LoadAsync();

                // Enable the 'Update Renderer' button now that the map has loaded
                UpdateRenderer.IsEnabled = true;
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }
        }