muk42 commited on
Commit
a8e42c9
·
1 Parent(s): 03b5da2

added reprojection to WGS84

Browse files
Files changed (1) hide show
  1. inference_tab/inference_logic.py +11 -2
inference_tab/inference_logic.py CHANGED
@@ -707,6 +707,14 @@ def fuzzyMatch(score_th, tile_dict):
707
  crs="EPSG:3857"
708
  )
709
 
 
 
 
 
 
 
 
 
710
  OSM_PATH = os.path.join(OUTPUT_DIR, "osm_extract.geojson")
711
  osm_gdf = gpd.read_file(OSM_PATH, dtype={"name": "str"})
712
  osm_gdf["name"] = osm_gdf["name"].str.replace("strasse", "", case=False, regex=False)
@@ -736,8 +744,8 @@ def fuzzyMatch(score_th, tile_dict):
736
 
737
  results.append({
738
  "blob_id": row.blob_id,
739
- "x": row.x,
740
- "y": row.y,
741
  "blob_name": row.pred_text,
742
  "best_osm_match": match[0] if match else None,
743
  "osm_match_score": match[1] if match else 0,
@@ -756,6 +764,7 @@ def fuzzyMatch(score_th, tile_dict):
756
  results_df.to_csv(RES_PATH, index=False)
757
 
758
  # Export OSM layer as CSV
 
759
  OSM_CSV_PATH = os.path.join(OUTPUT_DIR, f"osm_extract_tile{tile_number}.csv")
760
  osm_export_df = osm_gdf[["name", "geometry"]].copy()
761
  osm_export_df["geometry"] = osm_export_df["geometry"].apply(lambda g: g.wkt)
 
707
  crs="EPSG:3857"
708
  )
709
 
710
+ # Add lat lon to the blobs
711
+ # Reproject temporarily to WGS84 for coordinates
712
+ gdf_ll = gdf.to_crs(epsg=4326)
713
+
714
+ # Add longitude/latitude columns to the original gdf
715
+ gdf['lon'] = gdf_ll.geometry.x
716
+ gdf['lat'] = gdf_ll.geometry.y
717
+
718
  OSM_PATH = os.path.join(OUTPUT_DIR, "osm_extract.geojson")
719
  osm_gdf = gpd.read_file(OSM_PATH, dtype={"name": "str"})
720
  osm_gdf["name"] = osm_gdf["name"].str.replace("strasse", "", case=False, regex=False)
 
744
 
745
  results.append({
746
  "blob_id": row.blob_id,
747
+ "lon": row.lon,
748
+ "lat": row.lat,
749
  "blob_name": row.pred_text,
750
  "best_osm_match": match[0] if match else None,
751
  "osm_match_score": match[1] if match else 0,
 
764
  results_df.to_csv(RES_PATH, index=False)
765
 
766
  # Export OSM layer as CSV
767
+ osm_gdf = osm_gdf.to_crs(epsg=4326)
768
  OSM_CSV_PATH = os.path.join(OUTPUT_DIR, f"osm_extract_tile{tile_number}.csv")
769
  osm_export_df = osm_gdf[["name", "geometry"]].copy()
770
  osm_export_df["geometry"] = osm_export_df["geometry"].apply(lambda g: g.wkt)