{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/torchspatial-a-location-encoding-framework","title":"TorchSpatial: A Location Encoding Framework and Benchmark for Spatial Representation Learning","arxiv_id":"2406.15658","date":"2024-06-21","proceeding":null,"authors":["Nemin Wu","Qian Cao","Zhangyu Wang","Zeping Liu","Yanlin Qi","Jielu Zhang","Joshua Ni","Xiaobai Yao","Hongxu Ma","Lan Mu","Stefano Ermon","Tanuja Ganu","Akshay Nambi","Ni Lao","Gengchen Mai"],"abstract":"Spatial representation learning (SRL) aims at learning general-purpose neural network representations from various types of spatial data (e.g., points, polylines, polygons, networks, images, etc.) in their native formats. Learning good spatial representations is a fundamental problem for various downstream applications such as species distribution modeling, weather forecasting, trajectory generation, geographic question answering, etc. Even though SRL has become the foundation of almost all geospatial artificial intelligence (GeoAI) research, we have not yet seen significant efforts to develop an extensive deep learning framework and benchmark to support SRL model development and evaluation. To fill this gap, we propose TorchSpatial, a learning framework and benchmark for location (point) encoding, which is one of the most fundamental data types of spatial representation learning. TorchSpatial contains three key components: 1) a unified location encoding framework that consolidates 15 commonly recognized location encoders, ensuring scalability and reproducibility of the implementations; 2) the LocBench benchmark tasks encompassing 7 geo-aware image classification and 10 geo-aware image regression datasets; 3) a comprehensive suite of evaluation metrics to quantify geo-aware model's overall performance as well as their geographic bias, with a novel Geo-Bias Score metric. Finally, we provide a detailed analysis and insights into the model performance and geographic bias of different location encoders. We believe TorchSpatial will foster future advancement of spatial representation learning and spatial fairness in GeoAI research. The TorchSpatial model framework and LocBench benchmark are available at https://github.com/seai-lab/TorchSpatial, and the Geo-Bias Score evaluation framework is available at https://github.com/seai-lab/PyGBS.","url_abs":"https://arxiv.org/abs/2406.15658v3","url_pdf":"https://arxiv.org/pdf/2406.15658v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"torchspatial-a-location-encoding-framework","repo_url":"https://github.com/seai-lab/torchspatial","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"torchspatial-a-location-encoding-framework","repo_url":"https://github.com/seai-lab/pygbs","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"fairness","task_name":"Fairness"},{"task_slug":"geographic-question-answering","task_name":"Geographic Question Answering"},{"task_slug":"image-classification","task_name":"Image Classification"},{"task_slug":"question-answering","task_name":"Question Answering"},{"task_slug":"representation-learning","task_name":"Representation Learning"},{"task_slug":"weather-forecasting","task_name":"Weather Forecasting"},{"task_slug":"image-classification","task_name":"image-classification"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2406.15658","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2406.15658"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/seai-lab/TorchSpatial","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/seai-lab/pygbs","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/seai-lab/torchspatial","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":16,"ran_fixture":1,"ran_draft_wrong":3,"ran_violates":1,"unverified":1},"by_repo_kind":{"official":{"samples":22,"ran":21,"repositories":2}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"757cdfd8757676b2","entry":"auto_density","repo":"seai-lab/pygbs","repo_kind":"official","path":"baselines/gbsloss.py","file_url":"https://github.com/seai-lab/pygbs/blob/HEAD/baselines/gbsloss.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"757cdfd8757676b2"}},{"code_sha256_prefix":"ee66019898426cda","entry":"bce_loss","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/losses.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/losses.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ee66019898426cda"}},{"code_sha256_prefix":"ce1886c7a705a294","entry":"compute_kl_sri","repo":"seai-lab/pygbs","repo_kind":"official","path":"gbs/sri/sri_scores.py","file_url":"https://github.com/seai-lab/pygbs/blob/HEAD/gbs/sri/sri_scores.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ce1886c7a705a294"}},{"code_sha256_prefix":"eccb2504e6bf75c5","entry":"compute_mrr_by_lat","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/eval_analysis.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/eval_analysis.py","link_basis":"plan_row","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"eccb2504e6bf75c5"}},{"code_sha256_prefix":"f0c8a19e7f1331fe","entry":"compute_mrr_by_latlongrid","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/eval_analysis.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/eval_analysis.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f0c8a19e7f1331fe"}},{"code_sha256_prefix":"48bee5af4d1cdfec","entry":"compute_neighbor_prior","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/baselines.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/baselines.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"48bee5af4d1cdfec"}},{"code_sha256_prefix":"824c3511b683ed83","entry":"construct_weight_matrix","repo":"seai-lab/pygbs","repo_kind":"official","path":"baselines/gbsloss.py","file_url":"https://github.com/seai-lab/pygbs/blob/HEAD/baselines/gbsloss.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"824c3511b683ed83"}},{"code_sha256_prefix":"ec0ef856ad8a26b0","entry":"create_kde_grid","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/baselines.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/baselines.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ec0ef856ad8a26b0"}},{"code_sha256_prefix":"96cda1aea7b63917","entry":"embed_l2_normalize","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/losses.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/losses.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"96cda1aea7b63917"}},{"code_sha256_prefix":"b84f15b1635ddbda","entry":"generate_background_points","repo":"seai-lab/pygbs","repo_kind":"official","path":"baselines/gbsloss.py","file_url":"https://github.com/seai-lab/pygbs/blob/HEAD/baselines/gbsloss.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b84f15b1635ddbda"}},{"code_sha256_prefix":"063ddd72ea995d8a","entry":"get_activation_function","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/module.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/module.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"063ddd72ea995d8a"}},{"code_sha256_prefix":"d456c5cf4caf5297","entry":"get_label_rank","repo":"seai-lab/TorchSpatial","repo_kind":"official","path":"main/run_evaluation.py","file_url":"https://github.com/seai-lab/TorchSpatial/blob/HEAD/main/run_evaluation.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d456c5cf4caf5297"}},{"code_sha256_prefix":"fb680a92900a2a60","entry":"get_train_sample_ratio_tag","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/data_utils.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fb680a92900a2a60"}},{"code_sha256_prefix":"28855eb94bf07f6e","entry":"hashable_loc","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/baselines.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/baselines.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"28855eb94bf07f6e"}},{"code_sha256_prefix":"65b7b5e57148522e","entry":"load_bird_data","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/datasets.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/datasets.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"65b7b5e57148522e"}},{"code_sha256_prefix":"9d835b2cb9e2f146","entry":"load_mask","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/analysis.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/analysis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"9d835b2cb9e2f146"}},{"code_sha256_prefix":"3cfd8e042f3a9170","entry":"load_sparse_feats","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/datasets.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/datasets.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3cfd8e042f3a9170"}},{"code_sha256_prefix":"05bbcdadb7f81960","entry":"make_baseline_model_file","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/analysis.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/analysis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"05bbcdadb7f81960"}},{"code_sha256_prefix":"d54c93139380fbe0","entry":"make_model_res_file","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/data_utils.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d54c93139380fbe0"}},{"code_sha256_prefix":"89fc1fad0c9b5226","entry":"make_sphere_model_file","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/analysis.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/analysis.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"89fc1fad0c9b5226"}},{"code_sha256_prefix":"b6dbb6a8dbe80516","entry":"plot_locs","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/eval_analysis.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/eval_analysis.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b6dbb6a8dbe80516"}},{"code_sha256_prefix":"774c7aa6fadacf26","entry":"get_classes_sample_idxs","repo":"seai-lab/torchspatial","repo_kind":"official","path":"main/data_utils.py","file_url":"https://github.com/seai-lab/torchspatial/blob/HEAD/main/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"774c7aa6fadacf26"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}