diff --git a/server/ModelFromNVE/icemodellingscripts/__pycache__/getIceThicknessLakes.cpython-39.pyc b/server/ModelFromNVE/icemodellingscripts/__pycache__/getIceThicknessLakes.cpython-39.pyc
index 6fe0e8ef292c87abdb2a6e7852266f4f2db591a2..8012ed3d5bb1696ee750436aa9ef1dbc49a411e6 100644
Binary files a/server/ModelFromNVE/icemodellingscripts/__pycache__/getIceThicknessLakes.cpython-39.pyc and b/server/ModelFromNVE/icemodellingscripts/__pycache__/getIceThicknessLakes.cpython-39.pyc differ
diff --git a/server/data_processing/__pycache__/area_processing.cpython-39.pyc b/server/data_processing/__pycache__/area_processing.cpython-39.pyc
index f4bddf70c52a611a79882083f35d16cd83030e1e..0adb235536cb18d103470e2509eb05b2b21f7b5d 100644
Binary files a/server/data_processing/__pycache__/area_processing.cpython-39.pyc and b/server/data_processing/__pycache__/area_processing.cpython-39.pyc differ
diff --git a/server/data_processing/__pycache__/process_lidar_data.cpython-39.pyc b/server/data_processing/__pycache__/process_lidar_data.cpython-39.pyc
index 9070132a7d3582ef49167d1f01b94625cd9324e5..8b7e8aae44e6cac6f9bc7e3f344e192daf1e1b64 100644
Binary files a/server/data_processing/__pycache__/process_lidar_data.cpython-39.pyc and b/server/data_processing/__pycache__/process_lidar_data.cpython-39.pyc differ
diff --git a/server/data_processing/area_processing.py b/server/data_processing/area_processing.py
index 7ea4dfd5da7bd369d2d2c90292ff8e6eaf3d3eb4..8227da099ac2ebf75625177f6bad40b4852892e0 100644
--- a/server/data_processing/area_processing.py
+++ b/server/data_processing/area_processing.py
@@ -18,14 +18,14 @@ def position_relative_to_pointcloud(l1, l2, p1, p2, center_lim, max_lim):
         ((p2[0] - center_lim[0]) * ((l1[0] - l2[0]) / (max_lim[2][0] - max_lim[0][0])) + center_l[0],
             (p2[1] - center_lim[1]) * ((l1[1] - l2[1]) / (max_lim[2][1] - max_lim[0][1])) + center_l[1]),
     ]
-print(position_relative_to_pointcloud((-20,20), (-10,30), (1,3), (2,2), (2.5,2.5), [(5,5),(0,5),(0,0),(5,0)]))
-print(position_relative_to_pointcloud((-3299999, 4608018), (-3200001, 4687153), (61.47620866851029, 8.961138281887507), (61.95241733702057, 6.8508373935926645), (61, 11), [(61.95241733702057, 15.125349549679886), (60.04758266297943, 15.125349549679886), (60.04758266297943, 6.8746504503201145), (61.95241733702057, 6.8746504503201145)]))
+#print(position_relative_to_pointcloud((-20,20), (-10,30), (1,3), (2,2), (2.5,2.5), [(5,5),(0,5),(0,0),(5,0)]))
+#print(position_relative_to_pointcloud((-3299999, 4608018), (-3200001, 4687153), (61.47620866851029, 8.961138281887507), (61.95241733702057, 6.8508373935926645), (61, 11), [(61.95241733702057, 15.125349549679886), (60.04758266297943, 15.125349549679886), (60.04758266297943, 6.8746504503201145), (61.95241733702057, 6.8746504503201145)]))
 
 # check if lidar points is within range of the area selected
 def inArea(position, areaRange):
     x, y, _ = position # position to be checked
-    print((areaRange[0][0])," < ",x," < ",(areaRange[1][0])," and ",(areaRange[0][1])," > ",(y)," > ",(areaRange[1][1])," ",((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) > (y) > (areaRange[1][1])))
-    if ((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) > y > (areaRange[1][1])):
+    #print((areaRange[0][0])," < ",x," < ",(areaRange[1][0])," and ",(areaRange[0][1])," < ",(y)," < ",(areaRange[1][1])," ",((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) < (y) < (areaRange[1][1])))
+    if ((areaRange[0][0]) < x < (areaRange[1][0])) and ((areaRange[0][1]) < y < (areaRange[1][1])):
         return True
     else:
         return False
@@ -49,7 +49,8 @@ def closest_points(point, list, coords_taken):
 
 # Calculation of height in an area from las files
 def find_height(points):
-    print(points, " 5 ")
+    if len(points) == 0:
+        return [0]
     height_differences = [] # final container for height data
 
     # sort the points
@@ -116,8 +117,6 @@ def define_gridareas(lat, lng, area_offset, grid_size):
     subarea_offset_lng = offset_lng/grid_size
     subarea_offset_lat = offset_lat/grid_size
 
-    group_id = 0
-    i = 0
     # find the center coordinates of each area in grid to find the corner areas
     for y in (range(grid_size)):
         relative_size_lat = y / grid_size
@@ -125,19 +124,43 @@ def define_gridareas(lat, lng, area_offset, grid_size):
             relative_size_lng = x / grid_size
             lat_pos = main_area[3][0] + relative_size_lat * area_size[0] + dist_to_subcenter[0]
             lng_pos = main_area[3][1] + relative_size_lng * area_size[1] + dist_to_subcenter[1]
-            # id of each subarea
-            #sub_id = x % grid_size + grid_size * y
-
-            if (x+(y*grid_size)) % ((grid_size*2) + 1) == grid_size * 2:
-                group_id += 2
-
-            if (x+(y*grid_size)) % 2 == 0 and (x+(y*grid_size)) != 0:
-                i += 1
 
             # use the center of sub areas to find the corner of each subarea
             subarea_offset = (subarea_offset_lng, subarea_offset_lat)
             corners = calculate_corners(lat_pos, lng_pos, subarea_offset)
-            grided_area.append((group_id + i%2, corners))
+            grided_area.append(corners)
+
+    return grided_area
+
+# separate the zones into smaller area, into a grid
+def define_grid_lidardata(max_area, grid_size, points):
+    # container for an area turned into a grid of areas
+    grided_area = []
+
+    bottom_left, top_right = max_area
+
+    # find subareas size relative to the full size of data
+    subarea_offset_lng = (top_right[0]-bottom_left[0])/grid_size
+    subarea_offset_lat = (top_right[1]-bottom_left[1])/grid_size
+
+    # find the center coordinates of each area in grid to find the corner areas
+    for y in (range(grid_size)):
+        relative_size_lat = y / grid_size
+        for x in (range(grid_size)):
+            relative_size_lng = x / grid_size
+            bottom_left_range = (subarea_offset_lng * (relative_size_lng - 1 / 2) + bottom_left[0],
+                                 subarea_offset_lat * (relative_size_lat - 1 / 2) + bottom_left[1])
+
+            top_right_range = (subarea_offset_lng * relative_size_lng + bottom_left[0],
+                               subarea_offset_lat * relative_size_lat + bottom_left[1])
+
+            area_range = [bottom_left_range, top_right_range]
+
+            area = list(filter(lambda point_position: inArea(point_position, area_range), points))
+
+            height_in_area = find_height(area)
+
+            grided_area.append(height_in_area)
 
     return grided_area
 #[1,2,2,3,4,5,6,3,4,6,8,9,5,3,5.7,8,5,3]
diff --git a/server/data_processing/process_lidar_data.py b/server/data_processing/process_lidar_data.py
index 6e2992685935d82c4a8bb8bbe57768da49dfe477..83633ae16f88601ef72f3386d73e5d8c9a213bdf 100644
--- a/server/data_processing/process_lidar_data.py
+++ b/server/data_processing/process_lidar_data.py
@@ -5,7 +5,7 @@ import laspy
 import numpy as np
 
 from server.data_processing.area_processing import calculate_corners, define_gridareas, inArea, find_height, \
-    closest_points, position_relative_to_pointcloud
+    closest_points, position_relative_to_pointcloud, define_grid_lidardata
 
 # hard coded files for test datas
 lazData_path = ["server/example_lidar_data/ot_N_000005_1.laz", "server/example_lidar_data/ot_N_000033_1.laz"]
@@ -45,12 +45,17 @@ def calculate_area_data(center, body_of_water):
         map_data = json.load(data)
 
     # grid cell offset
+    # NB: make these a global var
+    grid_size = 4
     #cell_x, cell_y = map_data['tile_width'], map_data['tile_height']
+    #cell_x, cell_y = (400*grid_size, 400*grid_size)
     cell_x, cell_y = (2000, 1000)
 
     # convert the offset to meter
+    #cell_x = 111.320 * cell_x * 1000
+    #cell_y = (40075 * math.cos(cell_y) * 1000) / 360
     cell_x = 111.320 * cell_x
-    cell_y = 111.320 * math.cos(60) * cell_y
+    cell_y = (111.320 * math.cos(60)*cell_y)
 
     # set the limit of the area compared to local coordinates
     area_limit = calculate_corners(center[0], center[1], (cell_x, cell_y))
@@ -58,7 +63,7 @@ def calculate_area_data(center, body_of_water):
 
     # grid data
     map_data = map_data['features']
-    map_zones = [area_limit[1], area_limit[3]]
+    map_zones = [area_limit[2], area_limit[0]]
     map_data = list(filter(lambda point_position: inArea((point_position['properties']['sub_div_center'][0], point_position['properties']['sub_div_center'][1], 0.0), map_zones), map_data))
 
     # Refactor lidar data to a readable format
@@ -67,8 +72,9 @@ def calculate_area_data(center, body_of_water):
 
     # add two files together temporary test data(soon to be removed)
     ice_points = list(zip(iceOver.X,iceOver.Y,iceOver.Z)) + list(zip(iceUnder.X,iceUnder.Y,iceUnder.Z))
-    ice_points = list(filter(lambda point_position: inArea((point_position[0],point_position[1],0.0),[(-3300000,5000000), (-3200000,4500000)]),ice_points))
-
+    print(len(ice_points))
+    ice_points = list(filter(lambda point_position: inArea((point_position[0],point_position[1],0.0),[(-3300000, 4500000), (-3200000, 5000000)]), ice_points))
+    print(len(ice_points))
     # only for visualizating the testing data
     #print("max",max(ice_points))
     #print("min",min(ice_points))
@@ -87,55 +93,61 @@ def calculate_area_data(center, body_of_water):
     max_point = max(ice_points)
     min_point = min(ice_points)
 
+
     # define all the sub-areas within the area, local coordinates
-    grid_area_heights = define_gridareas(center[0], center[1], (cell_x, cell_y),4)
+    grid_sub_area = define_gridareas(center[0], center[1], (cell_x, cell_y),grid_size)
+    # define all the sub-areas within the area, lidar coordinates
+    grid_area_lidar_heights = define_grid_lidardata((min_point, max_point), grid_size, ice_points)
+
+    print('grid size: ', grid_sub_area)
+    print('grid size: ', grid_area_lidar_heights)
+    sub_area_heights = list(zip(grid_sub_area, grid_area_lidar_heights))
+    print('sub_area_heights: ', sub_area_heights[0])
+
     # find the heights of each sub-area => area-heights
     if len(map_data) > 0:
-        for sub_area in grid_area_heights:
-            start = (sub_area[1][2])
-            end = (sub_area[1][0])
+        for sub_area in sub_area_heights:
+            start = (sub_area[0][2])
+            end = (sub_area[0][0])
 
             #test data
             # zone coordinates sett to be relative to the lidar data's point cloud
-            print("l1 = ", min_point, " l2 = ", max_point)
-            print("p1 = ", start, " p2 = ", end)
-            print("center_lim = ", center)
-            print("max_lim = ", area_limit)
-            areazone = position_relative_to_pointcloud(min_point, max_point, start, end, center, area_limit)
-            print("area",areazone)
+            #print("l1 = ", min_point, " l2 = ", max_point)
+            #print("p1 = ", start, " p2 = ", end)
+            #print("center_lim = ", center)
+            #print("max_lim = ", area_limit)
+            #areazone = position_relative_to_pointcloud(min_point, max_point, start, end, center, area_limit)
+            #print("area",areazone)
             # calculate map zones height
             ys, xs = start
             ye, xe = end
             sub_center = ((xs + xe)/2, (ys + ye)/2)
             # check if area is part of water body
             part_of_subarea_of_waterbody = list(filter(lambda pos: inArea((pos['properties']['sub_div_center'][0], pos['properties']['sub_div_center'][1], 0.0), [start,end]), map_data))
+            print('sub_area: ', sub_area)
+            print('part_of_subarea_of_waterbody: ', part_of_subarea_of_waterbody)
             if(len(part_of_subarea_of_waterbody) > 0):
                 current_map_zone = closest_points(sub_center, part_of_subarea_of_waterbody, taken_coords)
                 sub_center = current_map_zone['properties']['sub_div_center']
                 taken_coords.append(sub_center)
                 print("item added", sub_center, " len ", len(taken_coords))
             else:
-                print("nothing here")
+                print("sub area not found on map")
                 continue
 
             current_zone_id = current_map_zone['properties']['sub_div_id']
 
             # filter data within sub-area zones
-            print(areazone[0][0]," < ",ice_points[0][0]," < ",areazone[1][0])
-            print(areazone[0][1]," > ",ice_points[0][1]," > ",areazone[1][1])
-            points_in_area = list(filter(lambda point_position: inArea(point_position, areazone), ice_points))
+            #print(areazone[0][0]," < ",ice_points[0][0]," < ",areazone[1][0])
+            #print(areazone[0][1]," > ",ice_points[0][1]," > ",areazone[1][1])
+            #points_in_area = list(filter(lambda point_position: inArea(point_position, areazone), ice_points))
 
-            if(len(points_in_area) > 0):
-                heights = find_height(points_in_area)
-
-                if current_map_zone is not None:
-                    area_heights.append((current_zone_id, sub_area[0], sub_center, heights))
-            else:
-                print("no points in area")
+            if current_map_zone is not None:
+                #                     sub_id        center         heights
+                area_heights.append((current_zone_id, sub_center, sub_area[1]))
         return area_heights
     else:
         return [] # return [0] if no data collected from lidar
 
 
-print(calculate_area_data((61, 11), 'mj\u00f8sa'))
-
+#print(calculate_area_data((61, 11), 'mj\u00f8sa'))
diff --git a/server/database/icedb b/server/database/icedb
index 182a178f4d22ecf48a1cb1e9354b9a38b22e417f..3eaa6a6e6eb2de02a879a08aea1dcf18658da9d3 100644
Binary files a/server/database/icedb and b/server/database/icedb differ
diff --git a/server/map_handler/__pycache__/add_new_lake.cpython-39.pyc b/server/map_handler/__pycache__/add_new_lake.cpython-39.pyc
index 780567c9714d6b96cd505ab89ce824157750580a..6942c14ec67b2f788cb482b3cf4ce7a327b9e877 100644
Binary files a/server/map_handler/__pycache__/add_new_lake.cpython-39.pyc and b/server/map_handler/__pycache__/add_new_lake.cpython-39.pyc differ
diff --git a/server/map_handler/__pycache__/get_lake_relation.cpython-39.pyc b/server/map_handler/__pycache__/get_lake_relation.cpython-39.pyc
index 070180dbaedd2b48960a200b62aba36c64532a44..804a787e754276654a428b758d0b5dfc9f59835c 100644
Binary files a/server/map_handler/__pycache__/get_lake_relation.cpython-39.pyc and b/server/map_handler/__pycache__/get_lake_relation.cpython-39.pyc differ
diff --git a/server/map_handler/__pycache__/get_measurements.cpython-39.pyc b/server/map_handler/__pycache__/get_measurements.cpython-39.pyc
index 96175633ac3d9fdad4da5c310fe90a26327ae321..9e215720e85a23d3df827a4da13542212a70ae15 100644
Binary files a/server/map_handler/__pycache__/get_measurements.cpython-39.pyc and b/server/map_handler/__pycache__/get_measurements.cpython-39.pyc differ
diff --git a/server/map_handler/__pycache__/input_new_data.cpython-39.pyc b/server/map_handler/__pycache__/input_new_data.cpython-39.pyc
index b0bbd9641aa470088d9ad7a7d894bc69a0da472b..2b5482a6634eb605346fe8fbabe43b4d43af0168 100644
Binary files a/server/map_handler/__pycache__/input_new_data.cpython-39.pyc and b/server/map_handler/__pycache__/input_new_data.cpython-39.pyc differ
diff --git a/server/map_handler/input_new_data.py b/server/map_handler/input_new_data.py
index 2ce5621e5089750f51ffa1a069d96812c58d8ebf..d94971863e10c9f1aa0fd6685c2c34143f89ae77 100644
--- a/server/map_handler/input_new_data.py
+++ b/server/map_handler/input_new_data.py
@@ -11,8 +11,6 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
         latitude = 60.816848
         longitude = 10.723823
 
-        total_measurement_average = 0  # the total average of a measurement
-
         # data about the file read from
         about_laz = about_laz_file()
         scale_factor = max(about_laz[2])
@@ -20,18 +18,16 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
         # create a new measurement with the time the data is sent, sensor type, where
         # and an estimate of average thickness of ice on water body
         cursor.execute('''
-            INSERT INTO Measurement(  SensorID, TimeMeasured, WaterBodyName, 
-                                        WholeAverageThickness, CenterLat, CenterLon) VALUES 
+            INSERT INTO Measurement(MeasurementID, SensorID, TimeMeasured, WaterBodyName, CenterLat, CenterLon) VALUES 
                 (?,?,?,?,?,?);
-        ''', (sensorId, datetime.utcnow().replace(microsecond=0), bodyOfWater, 0, latitude, longitude))
+        ''', (1, sensorId, datetime.utcnow().replace(microsecond=0), bodyOfWater, latitude, longitude))
 
         # auto generate new measurement id
         measurement_id = cursor.lastrowid
 
         # calculate the area of to be calculated based on the coordinates given to the calculation model
         areas_data = calculate_area_data((latitude, longitude), bodyOfWater)
-        print(bodyOfWater)
-        print(len(areas_data))
+
         lidar_json_data = []
 
         if(areas_data):
@@ -39,42 +35,40 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
             # calculate data for each zone within the area
             for area in areas_data:
                 # lng and lat relative to map
-                map_lat, map_lng = area[2]
+                subId = int(area[0])
+                map_lat, map_lng = area[1]
+                heights = area[2]
 
-                if(len(area[3]) != 0):
-                    average = sum(area[3])/len(area[3])
-                    minimum_thickness = min(area[3])
+                if(len(heights) != 0 or sum(heights) == 0):
+                    average = sum(heights)/len(heights)
+                    minimum_thickness = min(heights)
                 else:
                     average = 0
                     minimum_thickness = 0
 
-                total_measurement_average += average
-
+                time_measured = datetime.utcnow().replace(microsecond=0)
                 # input the data into the database
                 cursor.execute('''
-                INSERT INTO SubDivision(MeasurementID, SubDivisionID, GroupID, MinimumThickness, AverageThickness, CenterLatitude, CenterLongitude, Accuracy) VALUES
+                INSERT INTO SubdivisionMeasurementData(MeasurementID, TimeMeasured, SubdivID, WaterBodyName, MinimumThickness, AverageThickness, CalculatedSafety, Accuracy) VALUES
                     (?,?,?,?,?,?,?,?);
-                ''', (measurement_id, area[0], area[1], float(minimum_thickness), float(average), float(map_lat), float(map_lng), scale_factor))
-
+                ''', (measurement_id, time_measured, subId, bodyOfWater, float(minimum_thickness), float(average), float(0.0), scale_factor))
+                sub_center = (map_lat, map_lng)
                 # set up json formate
                 lidar_read = {
-                    'MeasurementId': measurement_id,
-                    'SubId': area[0],
-                    'GroupId': area[1],
-                    'SubCenter': (map_lat, map_lng),
-                    'Heights': area[3]
+                    'MeasurementId': str(measurement_id),
+                    'SubId': str(subId),
+                    'SubCenter': str(sub_center),
+                    'Heights': str(heights)
                 }
 
                 lidar_json_data.append(lidar_read)
 
-            total_measurement_average = total_measurement_average / len(areas_data)
-
             # input the newly generated measurement_id and whole average thickness
             cursor.execute('''
                 UPDATE Measurement
-                SET measurementID = ?, WholeAverageThickness = ?
-                WHERE MeasurementID IS NULL AND WholeAverageThickness = 0;
-            ''', (int(measurement_id), total_measurement_average), )
+                SET measurementID = ?
+                WHERE MeasurementID IS NULL;
+            ''', (int(measurement_id),))
         else:
             print('No data found, line 79')
 
@@ -85,10 +79,12 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
         self.send_response(200)
         self.send_header('Content-type', "application/json")
         self.end_headers()
-
-        file_path = "./lake_relation/newest_lidar_data.json"
+        file_path = "./server/map_handler/lake_relations/newest_lidar_data.json"
         content = None
 
+        current_directory = os.getcwd()
+        print("Current working directory:", current_directory)
+
         if len(lidar_json_data) > 0:
             if os.path.exists(file_path):
                 os.remove(file_path)
@@ -101,11 +97,12 @@ def input_new_Lidar_data(self, cursor, sensorId, bodyOfWater):
             print('No data found, line 101')
             content = json.dumps([])
 
+
         # Write content data to response object
         self.wfile.write(content.encode('utf-8'))
 
     # error handling
     except Exception as e:
-        print("An error occurred", e)
+        print("An error occurred: ", e)
         # rollback in case of error
-        cursor.connection.rollback()
\ No newline at end of file
+        cursor.connection.rollback()
diff --git a/server/map_handler/lake_relations/newest_lidar_data.json b/server/map_handler/lake_relations/newest_lidar_data.json
new file mode 100644
index 0000000000000000000000000000000000000000..80ff107e56ce4b3feeac75df937180040c0350a8
--- /dev/null
+++ b/server/map_handler/lake_relations/newest_lidar_data.json
@@ -0,0 +1 @@
+[{"MeasurementId": "17", "SubId": "48", "SubCenter": "(60.816856, 10.723847)", "Heights": "[1]"}, {"MeasurementId": "17", "SubId": "100", "SubCenter": "(60.816856, 10.990419)", "Heights": "[1, 27]"}, {"MeasurementId": "17", "SubId": "36", "SubCenter": "(60.756856, 10.710419)", "Heights": "[1]"}, {"MeasurementId": "17", "SubId": "168", "SubCenter": "(60.396856, 11.230419)", "Heights": "[1, 4, 6, 27, 7]"}]
\ No newline at end of file