psalama commited on
Commit
efe3888
·
1 Parent(s): 8dfb577

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -3,12 +3,27 @@ import geopandas as gpd
3
  import pandas as pd
4
  import os
5
  import matplotlib.pyplot as plt
 
6
  from shapely.geometry import shape
7
  from shapely.ops import unary_union
8
  #from datasets import load_dataset
9
 
10
  #ds = load_dataset('psalama/NYC_sensitive_sites', data_files=data_files)
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def process_buildings(input_gdf, sensitive_sites_gdf, default_building_height_m, multiplier_factor):
13
  # List to store all intersected sensitive sites
14
  intersected_sites = []
@@ -136,8 +151,11 @@ def ss_intersect(geojson1, ss_geoselect, multiplier_factor, default_building_hei
136
  # Calculate the maximum extent
137
  extent = get_max_extent(input_gdf, buffers_gdf)
138
 
 
 
 
139
  # Create and save the plot
140
- create_plot('output_image.png', extent, buffer_union_gdf, intersected_sites_gdf, input_gdf)
141
 
142
  # Return the image
143
  return 'output_image.png', "building_buffers.geojson", "buffer_union.geojson", intersection_desc
 
3
  import pandas as pd
4
  import os
5
  import matplotlib.pyplot as plt
6
+ from arcgis.features import FeatureLayer
7
  from shapely.geometry import shape
8
  from shapely.ops import unary_union
9
  #from datasets import load_dataset
10
 
11
  #ds = load_dataset('psalama/NYC_sensitive_sites', data_files=data_files)
12
 
13
+
14
+ def get_gdf_from_feature_layer(url):
15
+ # Access the ArcGIS feature layer
16
+ feature_layer = FeatureLayer(url)
17
+
18
+ # Use the query() method to get all features where 'Borough' is 'MN'
19
+ sdf = feature_layer.query(where="Borough='MN'", out_sr=4326, as_df=True)
20
+
21
+ # Convert the SpatialDataFrame to a GeoDataFrame
22
+ gdf = gpd.GeoDataFrame(sdf, geometry=gpd.points_from_xy(sdf['SHAPE.x'], sdf['SHAPE.y']))
23
+
24
+ return gdf
25
+
26
+
27
  def process_buildings(input_gdf, sensitive_sites_gdf, default_building_height_m, multiplier_factor):
28
  # List to store all intersected sensitive sites
29
  intersected_sites = []
 
151
  # Calculate the maximum extent
152
  extent = get_max_extent(input_gdf, buffers_gdf)
153
 
154
+ lots_url = "https://services5.arcgis.com/GfwWNkhOj9bNBqoJ/arcgis/rest/services/MAPPLUTO/FeatureServer/0" # Access MapPLUTO # Eventually should be a checkbox
155
+ lots_gdf = get_gdf_from_feature_layer(lots_url)
156
+
157
  # Create and save the plot
158
+ create_plot('output_image.png', extent, lots_gdf, buffer_union_gdf, intersected_sites_gdf, input_gdf)
159
 
160
  # Return the image
161
  return 'output_image.png', "building_buffers.geojson", "buffer_union.geojson", intersection_desc