diff --git a/frag_old_grow_forest/effective_mesh_size.R b/frag_old_grow_forest/effective_mesh_size.R
new file mode 100644
index 0000000000000000000000000000000000000000..37acf10302fc0c1c87db18760d9e08b485dcc055
--- /dev/null
+++ b/frag_old_grow_forest/effective_mesh_size.R
@@ -0,0 +1,156 @@
+# Remove all objects from the workspace (memory) of the R session
+rm(list=ls())
+gc()
+
+# load the required packages
+library(sf)
+library(dplyr)
+
+setwd("C:/Emmanuel_Oceguera_LocalW10sys/Evirionment_R")
+
+# Effective mesh size  
+# meff = (Atotal^2) / Σ(Ai^2)
+
+# Path to the shp
+forest_patches_path <-  "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/outputs/estonia/frag_patches_stonia.shp"
+estonia_path <- "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/data/NUTS2021_v22_Estonia.shp"
+
+# Open files
+forest_patches <- st_read(forest_patches_path)
+estonia <- st_read(estonia_path)
+
+# Effective mesh size equation 
+# meff = (Atotal^2) / Σ(Ai^2)
+
+# Define the sizes of the patches km²
+patches_sizes_km2 <- forest_patches %>% 
+  mutate(area_km2 = as.numeric(st_area(forest_patches)/1e6))
+
+# Define the total area of the country
+crty_total_km2 <- as.numeric(st_area(estonia)/1e6)
+
+# Calculate the squared area of the patches and sum of squered 
+patches_squared_km2 <- patches_sizes_km2$area_km2**2
+sum_patches_squared_km2 <- sum(patches_squared_km2)
+
+# Squared the total area of the country
+crty_total_squared_km2 <- crty_total_km2**2
+
+# calculate the meff using the formula
+estonia_meff_km2 <- crty_total_squared_km2/sum_patches_squared_km2
+
+# Merge meff values with the forest_patches data
+forest_patches_meff <- cbind(forest_patches, meff = estonia_meff_km2)
+
+# Print the result
+cat("Effective Mesh Size (meff) in square km^2:", estonia_meff_km2, "/n")
+
+# Result 
+"Effective Mesh Size (meff) in square km^2: 12017.86"
+
+
+# Visualization of the mesh size in Estonia
+# Create a ggplot object for the map
+ggplot() +
+  geom_sf(data = estonia, fill = "lightgray") +
+  geom_sf(data = forest_patches_meff, aes(fill = meff), color = NA) +
+  coord_sf(crs= 3035) +
+  scale_fill_gradient(low = "green", high = "red") +
+  theme_bw(base_line_size = NA) +
+  labs(title = "Effective Mesh Size (meff) Map for old grow Forest Patches in Estonia")
+
+
+
+# Save the result
+output_path <- "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/outputs/estonia"
+file_name <- paste0(output_path,"/", "estonia_meffkm2.shp")
+st_write(forest_patches_meff, file_name, driver = "ESRI Shapefile", overwrite= TRUE)
+
+
+
+# # Create a choropleth map
+# tm_shape(patches_sizes_km2) +  # Add borders to patches
+#   tm_fill(col = "area_km2", palette = "YlOrRd", title = "area km²", interactive = TRUE) +
+#   tm_borders(col = "black", lwd = 1, alpha = 0.5) + 
+#   tm_layout(legend.position = c("left", "bottom"), legend.outside = T) # Adjust legend position
+#   
+
+
+#  Croatia ----------------------------------------------------------------
+
+# load the required packages
+library(sf)
+library(dplyr)
+
+setwd("C:/Emmanuel_Oceguera_LocalW10sys/Evirionment_R")
+
+# Effective mesh size  
+# meff = (Atotal^2) / Σ(Ai^2)
+
+# Path to the shp
+forest_patches_path <-  "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/outputs/croatia/frag_patches_croatia.shp"
+croatia_path <- "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/data/NUTS2021_v22_Croatia.shp"
+
+# Open files
+forest_patches <- st_read(forest_patches_path)
+croatia <- st_read(croatia_path)
+
+
+# Effective mesh size equation 
+# meff = (Atotal^2) / Σ(Ai^2)
+
+# Define the sizes of the patches km²
+patches_sizes_km2 <- forest_patches %>% 
+  mutate(area_km2 = as.numeric(st_area(forest_patches)/1e6))
+
+
+# Define the total area of the country
+crty_total_km2 <- as.numeric(st_area(croatia)/1e6)
+
+# Calculate the squared area of the patches and sum of squered 
+patches_squared_km2 <- patches_sizes_km2$area_km2**2
+sum_patches_squared_km2 <- sum(patches_squared_km2)
+
+# Squared the total area of the country
+crty_total_squared_km2 <- crty_total_km2**2
+
+# calculate the meff using the formula
+croatia_meff_km2 <- crty_total_squared_km2/sum_patches_squared_km2
+
+# Merge meff values with the forest_patches data
+forest_patches_meff <- cbind(patches_sizes_km2, meff = croatia_meff_km2)
+
+# Print the result
+cat("Effective Mesh Size (meff):", croatia_meff_km2, "Km²")
+
+# Result 
+"Effective Mesh Size (meff): 852.0644 Km²"
+
+
+# Visualization of the mesh size in Estonia
+# Create a ggplot object for the map
+p <- ggplot() +
+  geom_sf(data = croatia, fill = "lightgray") +
+  geom_sf(data = forest_patches_meff, aes(fill = meff), color = NA) +
+  coord_sf(crs= 3035) +
+  scale_fill_gradient(low = "lightgreen", high = "darkgreen", name = "meff (km²)") +
+  theme_bw(base_line_size = NA) +
+  labs(title = "Effective Mesh Size (meff) Map for old grow Forest Patches in Croatia")
+
+
+
+# Save the result as shp
+output_path <- "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/outputs/croatia"
+file_name <- paste0(output_path,"/", "croatia_meffkm2.shp")
+st_write(forest_patches_meff, file_name, driver = "ESRI Shapefile", overwrite= TRUE)
+
+
+
+# # Create a choropleth map
+# tm_shape(patches_sizes_km2) +  # Add borders to patches
+#   tm_fill(col = "area_km2", palette = "YlOrRd", title = "area km²", interactive = TRUE) +
+#   tm_borders(col = "black", lwd = 1, alpha = 0.5) + 
+#   tm_layout(legend.position = c("left", "bottom"), legend.outside = T) # Adjust legend position
+#   
+
+
diff --git a/frag_old_grow_forest/effective_mesh_size_claculation.md b/frag_old_grow_forest/effective_mesh_size_claculation.md
new file mode 100644
index 0000000000000000000000000000000000000000..cee421c35365623fe1617c6b72145654cd0137e5
--- /dev/null
+++ b/frag_old_grow_forest/effective_mesh_size_claculation.md
@@ -0,0 +1,44 @@
+# Effective Mesh Size (meff) for Measuring Landscape Fragmentation
+
+## Introduction
+
+Landscape fragmentation is a critical concern in ecology and conservation, affecting both natural ecosystems and human societies. It refers to the division of continuous natural landscapes into smaller and often isolated patches or fragments. The effective mesh size (meff) is a metric used to quantify landscape fragmentation, providing valuable insights into the degree of landscape connectivity.
+
+## Formula
+
+The effective mesh size (meff) is calculated using the following formula:
+
+meff = (Atotal^2) / Σ(Ai^2)
+
+Where:
+- meff: Effective mesh size, a metric used to quantify landscape fragmentation.
+- Atotal: The total area of the region under investigation, encompassing all the patches.
+- Σ(Ai^2): The sum of the squared areas of each individual patch (Ai) within the landscape.
+
+## Calculation
+
+To calculate the effective mesh size (meff), follow these steps:
+
+1. Square the area of each patch (Ai^2) for all patches in the landscape.
+
+2. Sum up the squared areas of all the patches (Σ(Ai^2)).
+
+3. Square the total area of the landscape (Atotal^2).
+
+4. Divide the squared total area of the landscape by the sum of squared patch areas:
+
+   meff = (Atotal^2) / Σ(Ai^2)
+
+## Interpretation
+
+The result, meff, is a measure of the effective mesh size, which provides insight into the degree of fragmentation in the landscape. The interpretation of meff is as follows:
+
+- A larger meff value indicates a more connected and less fragmented landscape. This implies that the landscape has larger and fewer patches, with relatively higher connectivity.
+
+- A smaller meff value suggests a more fragmented landscape with smaller and more isolated patches. Lower meff values indicate reduced landscape connectivity and a higher degree of fragmentation.
+
+## Conclusion
+
+Landscape fragmentation has ecological, social, and economic implications, making meff a valuable metric for assessing and monitoring the impact of land use changes, habitat loss, and infrastructure development on natural landscapes. Understanding landscape fragmentation through meff can guide conservation and land use planning efforts to promote ecological connectivity and biodiversity conservation.
+
+Using the effective mesh size (meff) as a tool, researchers and policymakers can work towards preserving and restoring landscapes to maintain or enhance their ecological health and functionality.
diff --git a/frag_old_grow_forest/effective_mesh_size_function.R b/frag_old_grow_forest/effective_mesh_size_function.R
new file mode 100644
index 0000000000000000000000000000000000000000..9625bbf48c0f9b75bd8e7bca7678a1fe6b332992
--- /dev/null
+++ b/frag_old_grow_forest/effective_mesh_size_function.R
@@ -0,0 +1,50 @@
+# Remove all objects from the workspace (memory) of the R session
+rm(list=ls())
+gc()
+
+# load the required packages
+library(sf)
+library(dplyr)
+library(ggplot2)
+
+
+# claculate effective mesh size for country
+calculate_meff <- function(patch_shapefile_path, country_shapefile_path) {
+  # Read the shapefiles
+  forest_patches <- st_read(patch_shapefile_path)
+  estonia <- st_read(country_shapefile_path)
+  
+  # Calculate patch areas in km^2
+  patches_sizes_km2 <- forest_patches %>%
+    mutate(area_km2 = as.numeric(st_area(forest_patches) / 1e6))
+  
+  # Calculate the total area of the country in km^2
+  crty_total_km2 <- as.numeric(st_area(estonia) / 1e6)
+  
+  # Calculate the squared area of the patches and sum of squared areas
+  patches_squared_km2 <- patches_sizes_km2$area_km2^2
+  sum_patches_squared_km2 <- sum(patches_squared_km2)
+  
+  # Square the total area of the country
+  crty_total_squared_km2 <- crty_total_km2^2
+  
+  # Calculate the meff using the formula
+  estonia_meff_km2 <- crty_total_squared_km2 / sum_patches_squared_km2
+  
+  return(estonia_meff_km2)
+}
+
+
+# Path to the shp
+forest_patches_path <-  "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/outputs/estonia/frag_patches_stonia.shp"
+estonia_path <- "I:/biocon/Emmanuel_Oceguera/projects/2023_09_Fragmentation/data/NUTS2021_v22_Estonia.shp"
+
+
+# Example usage:
+estonia_meff_result <- calculate_meff(forest_patches_path, estonia_path)
+cat("Effective Mesh Size (meff) in square km^2:", estonia_meff_result, "\n")
+
+
+
+
+
diff --git a/frag_old_grow_forest/filter_forest.sql b/frag_old_grow_forest/filter_forest.sql
new file mode 100644
index 0000000000000000000000000000000000000000..fa9ddbeb5cc0abb0e18a4fcfd98eb0c0bab9b3bb
--- /dev/null
+++ b/frag_old_grow_forest/filter_forest.sql
@@ -0,0 +1,36 @@
+
+-- create a fragmentation patches
+
+CREATE TABLE fragmentation.frag_patches AS
+SELECT * FROM (
+	SELECT * FROM fragmentation.land_cover_primary_forest_points
+	UNION ALL
+	SELECT * FROM fragmentation.land_cover_primary_forest_polygons
+) AS land_cover_x_primary_forest
+WHERE code_18 IN ('311', '312', '313', '321', '322', '324');
+
+
+-- 311 -> Broad leaved forest
+-- 312 -> Coniferous forest
+-- 313 -> Mixed forest
+-- 321 -> Natural grasslands
+-- 322 -> Moors and heathland
+-- 324 -> Transitional woodland-shrub
+ 
+SELECT * FROM fragmentation.frag_patches
+
+
+
+-- create a fragmentation patches for Estonia
+
+CREATE TABLE fragmentation.frag_patches_estonia AS
+SELECT * FROM fragmentation."land_cover_primary_forest_polygons_EE"
+
+
+
+
+
+
+
+
+
diff --git a/frag_old_grow_forest/frag_old_grow_forest.Rproj b/frag_old_grow_forest/frag_old_grow_forest.Rproj
new file mode 100644
index 0000000000000000000000000000000000000000..8e3c2ebc99e2e337f7d69948b93529a437590b27
--- /dev/null
+++ b/frag_old_grow_forest/frag_old_grow_forest.Rproj
@@ -0,0 +1,13 @@
+Version: 1.0
+
+RestoreWorkspace: Default
+SaveWorkspace: Default
+AlwaysSaveHistory: Default
+
+EnableCodeIndexing: Yes
+UseSpacesForTab: Yes
+NumSpacesForTab: 2
+Encoding: UTF-8
+
+RnwWeave: Sweave
+LaTeX: pdfLaTeX