UjjwalKGupta commited on
Commit
882e722
·
verified ·
1 Parent(s): c66588a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -13
app.py CHANGED
@@ -32,16 +32,11 @@ def convert_to_2d_geometry(geom):
32
  if geom is None:
33
  return None
34
  elif geom.has_z:
35
- return transform(lambda geom: wkb.loads(wkb.dumps(geom, output_dimension=2)))
36
  else:
37
  return geom
38
-
39
- def validate_KML_file(gdf):
40
- # try:
41
- # gdf = gpd.read_file(BytesIO(uploaded_file.read()), driver='KML')
42
- # except Exception as e:
43
- # ValueError("Input must be a valid KML file.")
44
 
 
45
  if gdf.empty:
46
  return {
47
  'corner_points': None,
@@ -55,7 +50,7 @@ def validate_KML_file(gdf):
55
  if isinstance(gdf.iloc[0].geometry, Polygon) and len(gdf)==1:
56
  polygon_info['is_single_polygon'] = True
57
 
58
- polygon = convert_to_2d_geometry(gdf.geometry.iloc[0])
59
 
60
  # Calculate corner points in GCS projection
61
  polygon_info['corner_points'] = [
@@ -158,11 +153,6 @@ if uploaded_file is not None:
158
  st.write("It has centroid at ({0:.6f}, {1:.6f}).".format(polygon_info['centroid'][0], polygon_info['centroid'][1]))
159
  st.write("It has area of {:.2f} meter squared.".format(polygon_info['area']))
160
  st.write("It has perimeter of {:.2f} meters.".format(polygon_info['perimeter']))
161
-
162
- for i in range(len(gdf)):
163
- geom = gdf.iloc[i].geometry
164
- new_geom = convert_to_2d_geometry(geom)
165
- gdf.loc[i, 'geometry'] = new_geom
166
 
167
  #Read KML file
168
  geom_ee_object = ee.FeatureCollection(json.loads(gdf.to_json()))
 
32
  if geom is None:
33
  return None
34
  elif geom.has_z:
35
+ return transform(lambda x, y, z: (x, y), shape)
36
  else:
37
  return geom
 
 
 
 
 
 
38
 
39
+ def validate_KML_file(gdf):
40
  if gdf.empty:
41
  return {
42
  'corner_points': None,
 
50
  if isinstance(gdf.iloc[0].geometry, Polygon) and len(gdf)==1:
51
  polygon_info['is_single_polygon'] = True
52
 
53
+ polygon = convert_to_2d_geometry(gdf.iloc[0].geometry)
54
 
55
  # Calculate corner points in GCS projection
56
  polygon_info['corner_points'] = [
 
153
  st.write("It has centroid at ({0:.6f}, {1:.6f}).".format(polygon_info['centroid'][0], polygon_info['centroid'][1]))
154
  st.write("It has area of {:.2f} meter squared.".format(polygon_info['area']))
155
  st.write("It has perimeter of {:.2f} meters.".format(polygon_info['perimeter']))
 
 
 
 
 
156
 
157
  #Read KML file
158
  geom_ee_object = ee.FeatureCollection(json.loads(gdf.to_json()))