Proximity Analysis on Google Earth Engine

Proximity analysis is one approach to examining location of elements by estimating the distance among them and different elements nearby. The distance between one point to another might be estimated as a straight line or by following an arranged way, for example, a network analysis.

This analysis is commonly required for various spatial study like locating nearest health care center, site selection (bank, retail store, restaurant), it could indirectly help in business marketing. Many telecom companies rely on these geospatial analysis to expand their business.

In research work, proximity analysis is required to extract parameters for say human wildlife conflict, or analyzing changes in the land cover pattern. Proximity analysis is also helpful in identifying hazard conflict zones, after floods, landslides or any unfortunate natural occurrence. Many research based studies show that forecasting the flood model based on proximity may fortify future destruction and loss of habitat.

Dataset Used

I am using a derived dataset that is already available on Google Earth Engine — The World Settlement Footprint (WSF) 2015 data is of 10m resolution with an acquired date of 2014–2015 from multitemporal Landsat-8 (spatial resolution 30m) and Sentinel-1 (spatial resolution of 10m) imagery. Instead of Settlement data one can also import their vector datasets like road layer, railway lines or power lines.

For this analysis, a GPS data of 100 random points is obtained from Movebank.

Visualization of World Settlement Footprint 2015

Even though you are not from a coding background (like me 😉 ), you can easily visualize the datasets available in their data catalog. GEE platform has provided descriptive Python and Java APIs, to develop the code effortlessly. The World Settlement Data is the mask layer obtained from Landsat-8 and Sentinel-1 imagery. The built-up or settlement class is obtained after supervised classification using Support Vector Machines (SVMs) classifiers, for technical details on its methodology and accuracy, kindly refer to their paper.

var dataset = ee.Image("DLR/WSF/WSF2015/v1");
var opacity = 0.75;
var blackBackground = ee.Image(0);
Map.addLayer(blackBackground, null, "Black background", true, opacity);
var visualization = {
min: 0,
max: 255,
Map.addLayer(dataset, visualization, "Human settlement areas");
Map.setCenter(90.45, 23.7, 7);
Figure 1: Visualization of World Settlement Footprint 2015

Proximity Analysis in GEE

Step 1: Import raster and vector datasets. Also define the AOI (Area of interest) or the study.

var geometry = ee.Geometry.Polygon(
[[[36.03356337890625, -1.0677706066002322],
[36.03356337890625, -2.0753740460744834],
[37.673959497070314, -2.0753740460744834],
[37.673959497070314, -1.0677706066002322]]], null, false);
var GPS = ee.FeatureCollection("users/saumyatasrivastava/Data");
var raster = ee.Image("DLR/WSF/WSF2015/v1");
var opacity = 0.75;
var visualization = {
min: 255,
max: 255,
Map.addLayer(raster.clip(geometry), visualization, "Human settlement areas");
Map.setCenter(36.9558, -1.5394, 10);
Map.addLayer(GPS, {color: 'blue'}, "GPS");
print(GPS, "GPS")
Figure 2: Visualization of GPS points and Raster layer added

Step 2: Create the function to convert the raster layer of settlement to vector (Geometry, feature or feature collection). If you already have a vector layer of road, rail or other vector layer, then kindly skip this step.

var rasterPol = raster.reduceToVectors({geometry:geometry, scale:10,crs:'EPSG: 32644',maxPixels:1e13})var rasterPolGeo = rasterPol.geometry()
Map.addLayer(rasterPolGeo, {}, 'Settlement (Geometry)');

Step3: Create a function to map over each feature or each GPS point.

var Dist_Proximity = function(feature){
var point = feature.geometry()
var distance = rasterPolGeo.distance({'right': point, 'maxError': 1});

return feature.set({'distance':distance})

Step 4: Map over the ‘Dist_Proximity ‘ function and print the final result or export it in CSV format.

var Final_Result =
collection: Final_Result,

The final result will have an additional column named ‘distance’ added to the given GPS file.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store