UjjwalKGupta commited on
Commit
12359b7
·
verified ·
1 Parent(s): 4216354

Fix Geojson Parsing

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -63,10 +63,11 @@ def _process_spatial_data(data_bytes: BytesIO) -> gpd.GeoDataFrame:
63
  input_gdf = gpd.GeoDataFrame.from_features(features, crs="EPSG:4326")
64
  except Exception as e:
65
  raise ValueError(f"Failed to process KML data: {e}")
66
- # Otherwise, assume it's a format geopandas can read
67
  else:
68
  try:
69
- input_gdf = gpd.read_file(data_bytes)
 
70
  except Exception as e:
71
  raise ValueError(f"Failed to read GeoJSON or other vector data: {e}")
72
  return input_gdf
 
63
  input_gdf = gpd.GeoDataFrame.from_features(features, crs="EPSG:4326")
64
  except Exception as e:
65
  raise ValueError(f"Failed to process KML data: {e}")
66
+ # Otherwise, assume it's a format geopandas can read from databytes
67
  else:
68
  try:
69
+ geojson_str = data_bytes.read().decode('utf-8')
70
+ input_gdf = gpd.read_file(geojson_str)
71
  except Exception as e:
72
  raise ValueError(f"Failed to read GeoJSON or other vector data: {e}")
73
  return input_gdf