ARTICLE AD BOX
Hello I am trying to get distance of a given point to the coast, code editor says point is not defined, in the line 66 , but you can see it is already defined in the line 40.
I have no idea what the problem is
Thanks in advance.
I am not a programmer
Line 66: point is not defined >> is the error msg
// 2. Load Coastline (or use a water mask) var s2Coast = ee.FeatureCollection("projects/sat-io/open-datasets/S2COAST-2023") .filterBounds(caribe); // Create a panel to hold the coordinate input widgets. var panel = ui.Panel({ style: {width: '300px', shown: true} }); // Create text boxes for longitude and latitude. var lonTextbox = ui.Textbox({ placeholder: 'Enter Longitude...', style: {width: '200px'}, onChange: function(value) { // Optional: add real-time validation or processing here. } }); var latTextbox = ui.Textbox({ placeholder: 'Enter Latitude...', style: {width: '200px'}, onChange: function(value) { // Optional: add real-time validation or processing here. } }); // Create a button to process the coordinates and add the point to the map. var button = ui.Button({ label: 'Add Point to Map', onClick: function() { // Get the values from the text boxes. var lon = parseFloat(lonTextbox.getValue()); var lat = parseFloat(latTextbox.getValue()); // Validate the input. if (!isNaN(lon) && !isNaN(lat)) { // Create an Earth Engine Point geometry object. var point = ee.Geometry.Point(lon, lat); // Add the point to the map as a new layer. Map.centerObject(point, 10); // Center the map on the point with a zoom level Map.addLayer(point, {color: 'FF0000'}, 'User Point'); // Add a red point layer // Optional: print the coordinates to the console. print('Point added at: ' + lon + ', ' + lat); } else { print('Invalid coordinates entered. Please enter valid numbers.'); } } }); // Add the widgets to the panel. panel.add(ui.Label('Enter Point Coordinates')); panel.add(lonTextbox); panel.add(latTextbox); panel.add(button); // Add the panel to the map's UI. Map.add(panel); // Center the map to a default location (optional). Map.setCenter(-69.085, 10.422, 5); // 3. Calculate distance to the closest line (meters) var distance = point.distance({ right: s2Coast, maxError: 1 // Maximum error in meters });