Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ 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
|
@@ -14,12 +15,15 @@ from shapely.ops import unary_union
|
|
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=
|
23 |
|
24 |
return gdf
|
25 |
|
|
|
4 |
import os
|
5 |
import matplotlib.pyplot as plt
|
6 |
from arcgis.features import FeatureLayer
|
7 |
+
from arcgis.geometry import Geometry
|
8 |
from shapely.geometry import shape
|
9 |
from shapely.ops import unary_union
|
10 |
#from datasets import load_dataset
|
|
|
15 |
def get_gdf_from_feature_layer(url):
|
16 |
# Access the ArcGIS feature layer
|
17 |
feature_layer = FeatureLayer(url)
|
18 |
+
|
19 |
# Use the query() method to get all features where 'Borough' is 'MN'
|
20 |
sdf = feature_layer.query(where="Borough='MN'", out_sr=4326, as_df=True)
|
21 |
|
22 |
+
# Convert the 'SHAPE' column from ArcGIS's JSON-based format into a Shapely geometry
|
23 |
+
sdf['geometry'] = sdf['SHAPE'].apply(lambda x: Geometry(x).as_shapely)
|
24 |
+
|
25 |
# Convert the SpatialDataFrame to a GeoDataFrame
|
26 |
+
gdf = gpd.GeoDataFrame(sdf, geometry='geometry')
|
27 |
|
28 |
return gdf
|
29 |
|