diff --git a/city_metrix/layers/smart_surface_lulc.py b/city_metrix/layers/smart_surface_lulc.py index 49b1814..a8ce378 100644 --- a/city_metrix/layers/smart_surface_lulc.py +++ b/city_metrix/layers/smart_surface_lulc.py @@ -34,12 +34,12 @@ def get_data(self, bbox): # Open space open_space_osm = OpenStreetMap(osm_class=OpenStreetMapClass.OPEN_SPACE_HEAT).get_data(bbox).to_crs(crs).reset_index() - open_space_osm['Value'] = np.uint16(10) + open_space_osm['Value'] = 10 # Water water_osm = OpenStreetMap(osm_class=OpenStreetMapClass.WATER).get_data(bbox).to_crs(crs).reset_index() - water_osm['Value'] = np.uint16(20) + water_osm['Value'] = 20 # Roads @@ -60,7 +60,7 @@ def get_data(self, bbox): roads_osm['lanes'] = roads_osm['lanes'].fillna(roads_osm['avg_lanes']) # Add value field (30) - roads_osm['Value'] = np.uint16(30) + roads_osm['Value'] = 30 # Buffer roads by lanes * 10 ft (3.048 m) # https://nacto.org/publication/urban-street-design-guide/street-design-elements/lane-width/#:~:text=wider%20lane%20widths.-,Lane%20widths%20of%2010%20feet%20are%20appropriate%20in%20urban%20areas,be%20used%20in%20each%20direction @@ -74,7 +74,7 @@ def get_data(self, bbox): ) else: # Add value field (30) - roads_osm['Value'] = np.uint16(30) + roads_osm['Value'] = 30 # Building @@ -113,7 +113,7 @@ def get_data(self, bbox): # Parking parking_osm = OpenStreetMap(osm_class=OpenStreetMapClass.PARKING).get_data(bbox).to_crs(crs).reset_index() - parking_osm['Value'] = np.uint16(50) + parking_osm['Value'] = 50 # combine features: open space, water, road, building, parking diff --git a/city_metrix/models/building_classifier/building_classifier.pkl b/city_metrix/models/building_classifier/building_classifier.pkl index d1cee21..4907a22 100644 Binary files a/city_metrix/models/building_classifier/building_classifier.pkl and b/city_metrix/models/building_classifier/building_classifier.pkl differ diff --git a/city_metrix/models/building_classifier/building_classifier.py b/city_metrix/models/building_classifier/building_classifier.py index 08b5fce..816b690 100644 --- a/city_metrix/models/building_classifier/building_classifier.py +++ b/city_metrix/models/building_classifier/building_classifier.py @@ -50,8 +50,8 @@ def get_data_esa_reclass(self, bbox, crs): # Perform the reclassification reclassified_esa = reclassify(esa_world_cover, bins=list(reclass_map.keys()), new_values=list(reclass_map.values())) - # Convert to int8 and chunk the data for Dask processing - reclassified_esa = reclassified_esa.astype(np.uint16).chunk({'x': 512, 'y': 512}) + # Chunk the data for Dask processing + reclassified_esa = reclassified_esa.chunk({'x': 512, 'y': 512}) reclassified_esa = reclassified_esa.rio.write_crs(esa_world_cover.rio.crs, inplace=True) @@ -79,8 +79,8 @@ def get_data_ulu(self, bbox, crs, snap_to): for from_val, to_val in mapping.items(): ulu_lulc = ulu_lulc.where(ulu_lulc != from_val, to_val) - # Convert to int8 and chunk the data for Dask processing - ulu_lulc = ulu_lulc.astype(np.uint16).chunk({'x': 512, 'y': 512}) + # Chunk the data for Dask processing + ulu_lulc = ulu_lulc.chunk({'x': 512, 'y': 512}) ####### 1-Non-residential as default # 0-Unclassified as nodata @@ -112,7 +112,7 @@ def get_data_anbh(self, bbox, snap_to): def rasterize_polygon(self, gdf, snap_to): if gdf.empty: - raster = np.full(snap_to.shape, 0, dtype=np.uint16) + raster = np.full(snap_to.shape, 0) raster = xr.DataArray(raster, dims=snap_to.dims, coords=snap_to.coords) return raster.rio.write_crs(snap_to.rio.crs, inplace=True) @@ -121,7 +121,7 @@ def rasterize_polygon(self, gdf, snap_to): vector_data=gdf, measurements=["Value"], like=snap_to, - fill=np.uint16(0) + fill=0 ).Value return raster.rio.reproject_match(snap_to) @@ -149,7 +149,7 @@ def building_classifier_tree(self): # set classifier parameters clf = DecisionTreeClassifier(max_depth=5) # encode labels - buildings_sample['Slope_encoded'] = buildings_sample['Slope'].map({'low': np.uint16(42), 'high': np.uint16(40)}) + buildings_sample['Slope_encoded'] = buildings_sample['Slope'].map({'low': 42, 'high': 40}) # Select these rows for the training set build_train = buildings_sample[buildings_sample['Model']=='training'] diff --git a/environment.yml b/environment.yml index 24ec040..6470b62 100644 --- a/environment.yml +++ b/environment.yml @@ -21,7 +21,7 @@ dependencies: - geemap=0.32.0 - pip=23.3.1 - boto3=1.34.124 - - scikit-learn=1.5.0 + - scikit-learn=1.5.1 - pip: - git+https://github.com/isciences/exactextract - overturemaps==0.6.0 diff --git a/setup.py b/setup.py index 3124621..9d83e1d 100644 --- a/setup.py +++ b/setup.py @@ -30,6 +30,6 @@ "boto3", "exactextract", "overturemaps", - "scikit-learn>=1.5.0", + "scikit-learn>=1.5.1", ], )