Spatial data structures and coordinate systems
UAT 452 Remote Sensing and Geographic Information Systems for UAS
Lesson
By the end of this module you will be able to
- Explain vector and raster data and choose the right one for each kind of data
- Explain attribute tables, spatial relationships and common file formats
- Compute polygon area in a projected coordinate system and explain why degrees cannot be used
- Estimate raster data size and plan storage
- Explain datums and compute the coordinate shift when converting between datums
- Compute a stockpile volume from a DSM and assess the effect of an error in the base surface
Why this matters
A geographic information system (GIS) stores, manages, analyses and displays data with locations on Earth. The agriculture staff in the case study have drone images, field boundaries, canal lines and sampling points. Stored with the wrong structure or coordinate system, the data will not line up, areas will be wrong and files will be too large to open. This module lays the foundations of organising data before analysis.
Vector and raster
- Vector data store coordinates of points (such as sampling sites), lines (such as canals) and polygons (such as fields). Each feature has an attribute table holding other information, such as field code, owner, rice variety and transplanting date
- Raster data divide the area into equal cells, each storing a value such as reflectance, NDVI or height, suiting data that vary continuously; cells without data use a NoData value
Vectors have sharp boundaries, need little storage and suit counting and table joins. Rasters suit imagery and cell-by-cell computation. Real work stacks both as layers.
Spatial relationships and file formats
GIS is powerful because it answers spatial questions: which fields intersect the canal buffer, which samples lie within field P03, which fields touch a problem field. These relationships are topology. Field boundaries that overlap or leave small gaps between fields make analysis wrong, so geometry validity must be checked before use.
Common file formats:
- GeoPackage (.gpkg): one file can hold many vector and raster layers, and is the default format in current QGIS
- Shapefile (.shp): an older format still widely seen, made of several files, with column names limited to 10 characters; always send the .prj file that states the coordinate system
- GeoTIFF (.tif): a raster with its coordinate system embedded
Coordinate systems and area
GNSS receivers and many point files come in a geographic coordinate system (latitude and longitude in degrees), while Sentinel-2 Level-1C and Level-2A tiles are delivered already projected in the UTM zone of their tile (zone 47 or 48 over Thailand), so layers from different sources can arrive in different systems. Distances and areas need a projected system in metres, such as WGS 84 / UTM zone 47N (EPSG:32647). QGIS can display layers in different systems together by reprojecting on the fly, but areas must be computed in a suitable system.
Example 1 Field area in degrees is meaningless
A rectangular field near Rangsit, converted to metres with a local approximation that is accurate enough for small areas.
import math
R = 6371000.0 # mean Earth radius (m)
plot = [(100.6200, 14.0200), (100.6230, 14.0200), (100.6230, 14.0215), (100.6200, 14.0215)] # (longitude, latitude)
def shoelace(pts):
return abs(sum(x1 * y2 - x2 * y1 for (x1, y1), (x2, y2) in zip(pts, pts[1:] + pts[:1]))) / 2
lat0 = math.radians(sum(p[1] for p in plot) / len(plot))
local = [(R * math.cos(lat0) * math.radians(lon - plot[0][0]), R * math.radians(lat - plot[0][1])) for lon, lat in plot]
area = shoelace(local)
print(f"area in degrees^2 (meaningless): {shoelace(plot):.8f}")
print(f"area in metres: {area:,.0f} m2 = {area / 1600:.1f} rai")
area in degrees^2 (meaningless): 0.00000450
area in metres: 53,982 m2 = 33.7 rai
Applying the shoelace formula directly to degrees gives 0.0000045 “square degrees”, which has no meaning because a degree of longitude is not as long as a degree of latitude (at 14° latitude it is about 97% as long). Converted to metres, the field covers about 53,982 m², or about 33.7 rai (1 rai = 1,600 m²).
Raster data size
where is bytes per value (16-bit = 2 bytes).
Example 2 A multispectral image of 1 km² of paddy
import math
SIDE = 1000.0 # 1 × 1 km area
for gsd, bands, nbytes in [(0.03, 5, 2), (0.10, 5, 2), (10, 4, 2)]:
cells = SIDE / gsd
size = cells * cells * bands * nbytes
tiles = math.ceil(cells / 1024) ** 2 # number of 1024 × 1024 pixel tiles
print(f"GSD {gsd:>5} m: {cells:,.0f} x {cells:,.0f} cells, {bands} bands -> {size / 1e9:6.3f} GB, {tiles:,} tiles")
GSD 0.03 m: 33,333 x 33,333 cells, 5 bands -> 11.111 GB, 1,089 tiles
GSD 0.1 m: 10,000 x 10,000 cells, 5 bands -> 1.000 GB, 100 tiles
GSD 10 m: 100 x 100 cells, 4 bands -> 0.000 GB, 1 tiles
A five-band image at 3 cm is about 11 GB before compression. Reducing to 10 cm gives 1 GB, still clear enough for field-by-field monitoring. Storing tiles and overviews (pyramids) inside the file, as in a Cloud Optimized GeoTIFF, lets software read only the part being displayed, so large files open quickly.
Datums and converting coordinates between systems
The same coordinates can point to different places if they refer to different datums, the ellipsoids tied to the real Earth. Two systems turn up in Thailand: Indian 1975 (Everest 1830, 1937 Adjustment ellipsoid) and WGS 84, used by GNSS and drones. Indian 1975 / UTM zone 47N is EPSG:24047, against the EPSG:32647 of this module. The Royal Thai Survey Department reports that it recompiled the L7017 map series as L7018 on WGS 84 in 1997, while the Department of Lands still used Indian 1975 because land coordinates follow the law (Supavetch & Chunithipisan, 2012); the current position must be asked of the data owner. Conversion uses the chosen parameter set, for example EPSG:1304, which shifts the Earth-centred coordinates by (210, 814, 289) m with an accuracy of about 5 m.
Example 3 How far a plot corner moves if the datum is ignored
The plot corner from Example 1 was read from an Indian 1975 layer but then read directly as WGS 84.
import math
A1, F1 = 6377276.345, 1 / 300.8017 # Everest 1830 (1937 Adjustment) ellipsoid of Indian 1975
A2, F2 = 6378137.0, 1 / 298.257223563 # WGS 84 ellipsoid
DX, DY, DZ = 210.0, 814.0, 289.0 # EPSG:1304 geocentric translations (m)
lat, lon = 14.0200, 100.6200 # a plot corner read from an Indian 1975 layer
p, l = math.radians(lat), math.radians(lon)
e2 = F1 * (2 - F1)
w = 1 - e2 * math.sin(p) ** 2
m = A1 * (1 - e2) / w ** 1.5 # radius of curvature along the meridian
n = A1 / math.sqrt(w) # radius of curvature perpendicular to the meridian
dp = (-DX * math.sin(p) * math.cos(l) - DY * math.sin(p) * math.sin(l) + DZ * math.cos(p)
+ (A1 * (F2 - F1) + F1 * (A2 - A1)) * math.sin(2 * p)) / m # abridged Molodensky formula proposed by the Survey Department: change of latitude (radians)
dl = (-DX * math.sin(l) + DY * math.cos(l)) / (n * math.cos(p)) # change of longitude (radians)
dn, de = dp * m, dl * n * math.cos(p)
print(f"shift if the datum is ignored: {de:.0f} m east, {dn:.0f} m north, {math.hypot(de, dn):.0f} m in total")
shift if the datum is ignored: -356 m east, 182 m north, 400 m in total
The same point lies 400 m away, more than the plot of Example 1 (about 324 x 166 m), so a plot boundary overlaid without converting the datum lands on the wrong plot. The result differs from pyproj (EPSG:1304) by less than 1 m, but pyproj 3.8.0 picks EPSG:1812 as its default, and that set places the same point about 190 m away. Always record which parameter set was used, and use the one the data owner specifies.
Stockpile and earthwork volume from surface models
Area-based work such as quarries, stockyards and construction sites needs volumes. A DSM raster makes this simple: treat each cell as a column whose base is the cell area and whose height is the difference from a base surface, and add only the cells above the base, . The base can be a plane through the toe points, a surface drawn from the pile outline, or the model from an earlier survey. The volume depends on the base surface more than on anything else.
Construction work subtracts two surveys cell by cell. The result is a DoD (DEM of difference): positive cells are fill, negative cells are cut, and they are summed separately. Cells that changed less than the minimum level of detection, set from the error of both models, are not counted (Wheaton et al., 2010). Raeva et al. (2016) compared the volume of a stockpile in an open pit quarry from a drone with GNSS and note that mining rules often require the volume within ±3% of the total.
Example 4 Volume of a crushed-rock stockpile in a quarry
The DSM of the pile (assumed) is coarsened to 2 m cells to keep the example short; real work uses about 5-10 cm. The base is a plane at the level of the toe points.
CELL = 2.0 # DSM cell size (m)
BASE = 100.0 # base plane from the toe points (m)
dsm = [[100.0, 100.4, 100.9, 101.1, 100.8, 100.3, 100.0],
[100.3, 101.5, 102.6, 103.0, 102.4, 101.2, 100.2],
[100.5, 102.2, 103.8, 104.3, 103.5, 101.9, 100.4],
[100.4, 101.8, 103.1, 103.6, 102.9, 101.6, 100.3],
[100.1, 100.7, 101.4, 101.7, 101.2, 100.6, 100.0]]
dz = [z - BASE for row in dsm for z in row if z > BASE]
vol = sum(dz) * CELL ** 2
foot = len(dz) * CELL ** 2
print(f"footprint {foot:.0f} m2, volume {vol:.1f} m3")
for err in (0.05, 0.10): # base surface too high (m)
print(f"base {err:.2f} m too high -> volume {vol - err * foot:.1f} m3 ({-err * foot / vol:+.1%})")
footprint 128 m2, volume 202.8 m3
base 0.05 m too high -> volume 196.4 m3 (-3.2%)
base 0.10 m too high -> volume 190.0 m3 (-6.3%)
The pile holds about 202.8 m³ on a 128 m² footprint. A base only 5 cm too high removes 3.2%, already outside ±3%. Low, wide piles are very sensitive to the base, so measure the toe points with GNSS RTK or tie them to GCPs and record which base surface was used.
Module lab
Lab: build the project database
- Create a GeoPackage in EPSG:32647 with layers for fields (polygons), canals (lines) and sampling points (points), each with an attribute table you design
- Digitise field boundaries from the orthomosaic, check geometry validity with the QGIS checking tools, and fix overlaps and gaps
- Compute each field’s area in square metres and rai, and compare one field with the code in Example 1
- Estimate the project’s raster file sizes with the code in Example 2, and build overviews for the orthomosaic
- Export the fields layer as a Shapefile and check that column names and the coordinate system are still correct
Common mistakes
Watch out
- Computing area in a geographic coordinate system and getting a number in degrees
- Sending a Shapefile without the .prj file, so the recipient does not know the coordinate system
- Overlapping or gapped field boundaries, giving wrong totals and overlays
- Always keeping the full-resolution ortho without asking what the job needs, until computers cannot open it
- Designing attribute tables without a unique field code, so other data cannot be joined
Summary
- Vector data store points, lines and polygons with attribute tables; raster data store values in a grid of cells
- Topology and geometry validity must be checked before analysis; GeoPackage holds many layers in one file
- Measure distance and area in a projected system in metres, not degrees
- Raster size ; choose resolution to suit the job and use tiles and overviews
Check your understanding
- In the case study, which data suit vector and which suit raster?
- How many rai is an 8,000 m² field?
- What is the uncompressed size of a 10,000 × 10,000 cell, 4-band, 16-bit image?
- Why is area in square degrees meaningless?
- Which file must accompany a Shapefile so the coordinate system is known?
Answers
- Vector: fields, canals, sampling points. Raster: orthomosaic, NDVI, heights
- rai
- bytes, or 0.8 GB
- Degrees of longitude and latitude differ in length and change with latitude, so the unit is not constant
- The .prj file
Key formulas
| Shoelace formula | |
| Local degrees to metres | |
| Raster size | |
| Geocentric translation | |
| Volume above a base surface |
Key references
- Longley, P. A., Goodchild, M. F., Maguire, D. J., & Rhind, D. W. (2015). Geographic information science and systems (4th ed.). Wiley.
- QGIS Project. QGIS user guide. link
- IOGP. WGS 84 / UTM zone 47N (EPSG:32647). EPSG geodetic parameter dataset. link
- Lillesand, T., Kiefer, R. W., & Chipman, J. (2015). Remote sensing and image interpretation (7th ed.). Wiley. link
- European Space Agency. S2 products. SentiWiki (Copernicus). link
- IOGP. Indian 1975 / UTM zone 47N (EPSG:24047). EPSG geodetic parameter dataset. link
- IOGP. Indian 1975 to WGS 84 (2) (EPSG:1304) [Coordinate operation]. EPSG geodetic parameter dataset. link
- Supavetch, S., & Chunithipisan, S. (2012). The development of RTSD coordinates transformation service for mobile device. In Proceedings of the Asian Conference on Remote Sensing 2012 (ACRS 2012). Asian Association on Remote Sensing. link
- OpenDroneMap Authors. Outputs. OpenDroneMap documentation (Version 3.6.0). link
- Wheaton, J. M., Brasington, J., Darby, S. E., & Sear, D. A. (2010). Accounting for uncertainty in DEMs from repeat topographic surveys: Improved sediment budgets. Earth Surface Processes and Landforms, 35(2), 136–156. link
- Raeva, P. L., Filipova, S. L., & Filipov, D. G. (2016). Volume computation of a stockpile: A study case comparing GPS and UAV measurements in an open pit quarry. The International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, XLI-B1, 999-1004. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
In class / field
Lab or field practice from worksheets with a safety checklist
Learning evidence: Checked worksheets and quiz results