Project

View on GitHub
Sample viewer app

Project a point to another spatial reference.

Image of project

Use case

Being able to project between spatial references is fundamental to a GIS. An example of when you would need to re-project data is if you had data in two different spatial references, but wanted to perform an intersect analysis with the class AGSGeometryEngine.intersection(ofGeometry1:geometry2:) method. This method takes two geometries as parameters, and both geometries must be in the same spatial reference. If they are not, you could first use class AGSGeometryEngine.projectGeometry(_:to:) to convert the geometries so they match.

How to use the sample

Tap anywhere on the map. A callout will display the tapped location's coordinate in the original (basemap's) spatial reference webMercator and in the projected spatial reference wgs84.

How it works

  1. Call the static method, class AGSGeometryEngine.projectGeometry(_:to:) passing in the original geometry and a spatial reference to which it should be projected.

Relevant API

  • AGSGeometryEngine
  • AGSPoint
  • AGSSpatialReference

Additional information

In cases where the the output spatial reference uses a different geographic coordinate system than that of the input spatial reference, see the class AGSGeometryEngine.projectGeometry(_:to:datumTransformation:) method that additionally takes in an AGSDatumTransformation parameter.

Tags

coordinate system, coordinates, latitude, longitude, projected, projection, spatial reference, Web Mercator, WGS 84

Sample Code

ProjectStackView.swiftProjectViewController.swift
                     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright 2019 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import UIKit

class ProjectStackView: UIStackView {
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var originalLabel: UILabel!
    @IBOutlet weak var projectedLabel: UILabel!
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.