Reference systems for location Coordinates Switch between degrees
Reference systems for location Coordinates Switch between degrees, meters and pixels Measure distances Mobile CSP Pierre Huguet pierre. huguet 50@gmail. com
Coordinate systems ? • When handling geographic data you will meet several coordinate systems : – Geographic coordinates for latitude and longitude (in degrees), – Cartographic coordinates (in meters or kilometers), – Screen coordinates (in pixels). • You will have to convert locations between coordinate systems to : – – – Measure distance (kilometers) between 2 points (known in degrees), Compute latitude and longitude of the pixel you clicked, Display accuracy (in meters) around locations (in degrees), Drag a map to pan (i. e. change map center from screen drag), Plot objects with size known in meters, … This tutorial tells you how to do this. 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
1. Geographic coordinate system (simplified definitions) • Latitude is an angle that specifies the north–south position of a point on the Earth's surface. It ranges from -90° at the south pole, 0° at the equator to +90° at the north pole. • Longitude is an angle that specifies the east-west position of a point on the Earth's surface. 0° at the Prime Meridian in Greenwich. It ranges from − 180° westward to +180° eastward. • Altitude is the height in meters above mean sea level (MSL), not to be confused with height above ground (AGL). Terrain elevation is the altitude (MSL) of the ground itself. There are many definitions of latitudes and longitudes. WGS 84 is the most common. Its absolute precision is around 1 m. Within this tutorial, we will assume that the earth is spherical (which is quite OK for what we need). 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
2. Cartographic coordinate systems • Paper or digital maps are a representation of the spherical earth on a flat surface. Maps use a cartesian (x, y) coordinate system with a scale that tries to preserve the aspect ratio of objects and to enable easy distance measurements. Cartographic coordinates (m) Higher scales : square pixels in meters • This is only possible for higher scales (ex : topographic maps). Distance ratios can not be kept at small scales (see world map). Geographic coordinates (°) • We will here focus on high scales or zoom factors. When x/y aspect ratio is kept : pixels are ~square in meters and ~rectangles in degrees. Very small scales : 10/2016 Location and GPS tutorial for App Inventor, rectangular pixels in degrees pierre. huguet 50@gmail. com
3. Screen or window coordinates • The screen or window is a flat surface (like a paper map) that uses a cartesian coordinate system, with : – – Pixel units, Coordinate origins (0, 0) top left, X goes from left to right (width), Y goes from top to bottom (height). • Compared to cartographic and geographic coordinates, there is an inversion on the Y axis. • Orientation and angles : as for maps orientations start at 0 from north going clockwise to 360° 10/2016 Location and GPS tutorial for App Inventor, Angles from north pierre. huguet 50@gmail. com
Functions explained and provided in next slides 1. Length in meters of a degree of latitude and longitude, 2. Measure distance in meters between 2 points located by their latitude and longitude, – We will compute distance on the spherical earth, or "great circle" distance (bird’s fly : not the straight line or shortest tunnel). 3. Compute pixel size : 3. 1 in meters : used when plotting objects with metric size (ex : accuracy), 3. 2 in degrees of longitude and latitude : used when dragging to pan, 4. Convert pixel-canvas coordinates to/from geographic coordinates : 4. 1 Compute longitude and latitude from pixel canvas coordinates, 4. 2 Compute pixel coordinates from longitude and latitude. 5. Practice 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
1. Length in meters of one degree of latitude and of longitude • As an effort to share universal units worldwide, the meter was first defined in 1791 as 1/10 000 of half of a meridian of the earth. Ø a degree of latitude is equal to 4 * 40 000 / 360° ~ 111 m However, we will here assume a spherical earth with an average radius rounded to 6 371 km leading to 1° = 111 195 m With App inventor code here Ø a degree of longitude changes with latitude degree of longitude = degree of latitude * cosine (latitude) with the corresponding App inventor code here Note : putting an other planet’s radius will do the job for this planet 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
2. "great circle" or shortest distance between points known by their longitude and latitude f • This distance is but the equivalent Vincenty formula is better fit for computation • and translates into the following blocks : 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
3. 1 Pixel size in meters ? (valid for zoom levels >7) • 10/2016 Location and GPS tutorial for App Inventor, zoom 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 pierre. huguet 50@gmail. com pixel size in meters 3200 1600 800 400 200 100 50 25 12, 5 6, 25 3, 125 1, 5625 0, 7813 0, 3906 0, 1953 0, 0977
3. 2 Pixel size in longitude and latitude (for zoom levels >7) • 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
3. Blocks for pixel size in meters, pixel height and width in degrees Pixel size in meters (for zoom levels >7) Pixel height in degrees of latitude (for zoom levels >7) Pixel width in degrees of longitude (for zoom levels >7) 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
• for pixel x, y returned by blocks it follows : 10/2016 Location and GPS tutorial for App Inventor, 1, 1 1, 2 Canvas width Y=0 x 1, canvas width 2, 1 Center latitude Canvas height /2 Canvas height y Center longitude – in green : canvas pixels with center position and x, y number, – in red : center latitude and longitude, pixel height and width (degrees), – in blue : physical screen coordinates (canvas units) X=0 • Figure on the right shows : Canvas width /2 4. 1 Compute longitude and latitude from pixel-canvas coordinates (zoom levels >7) pixel width pixel height pierre. huguet 50@gmail. com
4. 2 Compute pixel-canvas coordinates from longitude and latitude (zoom levels >7) • Inversion of the previous functions is straightforward : a point with "latitude, longitude" coordinates should be plotted at x, y given by : (… if coordinates are within canvas) 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
4. pixel-canvas / longitude-latitude conversion blocks (zoom levels >7) longitude from pixel x (and center lat) latitude from pixel y x from latitude and center y from latitude and center 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
Practice • Coming soon 10/2016 Location and GPS tutorial for App Inventor, pierre. huguet 50@gmail. com
- Slides: 15