Data extraction method and apparatus for spatial analysis
By constructing regular expressions and geographic distribution scoring models to determine baseline coordinates, and combining differential filtering and image naming techniques, the accuracy and applicability issues of data extraction in spatial analysis are solved, achieving efficient structured data extraction and supporting urban planning and environmental assessment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGZHOU URBAN PLANNING & DESIGN SURVEY RES INST
- Filing Date
- 2026-05-12
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies suffer from problems in spatial analysis, such as coordinate parsing errors, insufficient judgment of the rationality of coordinate values, lack of differentiation in the selection of spatial point data, and unreasonable naming of document images, which affect the accuracy and applicability of data extraction.
Coordinate values are extracted by constructing regular expressions compatible with multiple delimiters, benchmark coordinates are determined using a geographic distribution rationality scoring model, spatial point data is filtered differentially, and images are named based on the geometric relationship and layout features between images and documents.
It enables efficient and accurate extraction of structured data from multi-source heterogeneous data, solves the problems of coordinate misalignment and data type differences, improves the efficiency and reliability of data preparation, and provides a reliable data foundation for urban planning and environmental assessment.
Smart Images

Figure CN122489984A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a data extraction method and apparatus for spatial analysis. Background Technology
[0002] In the field of spatial data analysis and geographic information processing, extracting spatial correlation data of a target site from multi-source heterogeneous data is fundamental for applications such as site analysis, environmental assessment, and facility planning. Typically, the required data comes from coordinate text files, spatial point data files, and related case documents. Existing technologies have developed various data cleaning, matching, and fusion methods for processing such data.
[0003] In some existing solutions, seed addresses are used to match and correct erroneous addresses in the address database, improving the accuracy of address data. Other solutions utilize dynamic knowledge graphs, cross-modal alignment, and large language models to achieve semantic alignment and fusion processing of multimodal data such as text, images, and time series. For unstructured addresses containing fuzzy modifiers, some solutions employ multi-geocoding service collaboration and probabilistic models to obtain optimal coordinates.
[0004] However, the aforementioned existing technologies still have the following shortcomings in data extraction scenarios for spatial analysis: First, when extracting coordinate values from coordinate text files, the order in which longitude and latitude are recorded often differs across data sources. Existing technologies typically default to a fixed order or require users to manually specify the longitude-latitude correspondence. When the file format is ambiguous or the recording order does not match expectations, it can easily lead to coordinate parsing errors, causing subsequent spatial distance calculations based on those coordinates to lose accuracy.
[0005] Second, existing technologies lack effective means to verify the reasonableness of coordinate pairs extracted from text files. Without prior knowledge of the coordinate value correspondence, existing methods struggle to automatically determine which value should be used as latitude and which as longitude, thus failing to guarantee the geographical accuracy of the determined baseline coordinates.
[0006] Third, after obtaining the baseline coordinates, existing technologies typically employ a uniform distance filtering method for various data points in spatial point data files, such as simple radius truncation or distance sorting. However, in practical applications, different types of spatial point data (such as fixed facility points and mobile acquisition points) have different requirements in spatial correlation analysis, and a uniform filtering strategy is difficult to simultaneously meet the specific requirements of multiple data types.
[0007] Fourth, when parsing case documents, existing technologies often focus on extracting textual information, while the processing of images embedded in the documents is rather crude. For example, images are usually saved only with their original filenames or simple numbers, lacking a mechanism to automatically obtain their semantic names. This makes it difficult to effectively integrate images with textual information, limiting the effectiveness of subsequent multimodal data fusion analysis.
[0008] In summary, existing technologies still have significant shortcomings in areas such as automatic error correction in coordinate extraction, determination of the rationality of coordinate values, differentiated screening of spatial point data, and naming of document images, which affect the overall accuracy and applicability of spatial analysis data extraction. Summary of the Invention
[0009] The purpose of this invention is to overcome the shortcomings of the prior art and provide a technique that can automatically, accurately, and efficiently extract structured data for spatial analysis from multi-source heterogeneous data.
[0010] The objective of this invention is achieved through the following technical solution: Therefore, according to one aspect of the present invention, a data extraction method for spatial analysis is provided, comprising the following steps: obtaining a coordinate text file and a spatial point data file of a target site; extracting a first coordinate value and a second coordinate value from the coordinate text file using a regular expression compatible with multiple delimiters; constructing a corresponding original coordinate sequence and an inverted coordinate sequence based on the first coordinate value and the second coordinate value, and competitively scoring the original coordinate sequence and the inverted coordinate sequence using a preset geographical distribution rationality scoring model; determining the mapping relationship between the first coordinate value and the second coordinate value as a reference latitude and a reference longitude, respectively, based on the results of the competitive scoring, to output the reference coordinates; calculating the spherical distance between each data point in the spatial point data file and the reference coordinates based on the reference coordinates; and performing differential filtering related to data type on each data point in the spatial point data file according to the spherical distance to obtain a data subset spatially associated with the target site.
[0011] Specifically, a competitive scoring method is used to evaluate the original coordinate sequence and the inverted coordinate sequence using a pre-defined geographical distribution rationality scoring model. This includes the following steps: inputting the first coordinate value as a latitude candidate value and the second coordinate value as a longitude candidate value into the geographical distribution rationality scoring model to calculate the final score of the original coordinate sequence; inputting the first coordinate value as a longitude candidate value and the second coordinate value as a latitude candidate value into the geographical distribution rationality scoring model to calculate the final score of the inverted coordinate sequence. The geographical distribution rationality scoring model is configured to: assign corresponding latitude and longitude scores to the input coordinate sequence based on the pre-defined geographical range in which its latitude and longitude values fall, and sum the latitude and longitude scores to calculate the corresponding final score.
[0012] More specifically, based on the results of the competitive scoring, the first coordinate value and the second coordinate value are determined as the mapping relationship between the reference latitude and the reference longitude, respectively. This includes the following steps: comparing the final scores of the original coordinate sequence and the inverted coordinate sequence; if the final score of the original coordinate sequence is higher than the final score of the inverted coordinate sequence, then the first coordinate value is determined to be latitude and the second coordinate value to be longitude; if the final score of the inverted coordinate sequence is higher than the final score of the original coordinate sequence, then the first coordinate value is determined to be longitude and the second coordinate value to be latitude; if the final scores of the original coordinate sequence and the inverted coordinate sequence are the same, then a downgrade check is performed: determining whether the absolute value of the first coordinate value is greater than 90 and the absolute value of the second coordinate value is less than or equal to 90; if so, then the first coordinate value is determined to be longitude and the second coordinate value to be latitude; otherwise, the first coordinate value is determined to be latitude and the second coordinate value to be longitude.
[0013] Another specific step involves performing differential filtering based on data type, which includes the following steps: identifying the data type of each point in the spatial point data file, including facility point data and environmental image acquisition point data; for data points of facility point data type, performing a first filtering strategy: comparing the calculated spherical distance with a preset radius threshold, and retaining data points whose distance is less than or equal to the radius threshold to form a first data subset; for data points of environmental image acquisition point data type, performing a second filtering strategy: sorting the data points in ascending order according to the calculated spherical distance, and retaining the top N data points to form a second data subset.
[0014] In another specific instance, the method also includes the following steps: obtaining case documents for the target site; parsing the case documents to extract structured text information and images, and formatting and naming the images; and integrating the data subset spatially associated with the target site, the structured text information, and the named images. The process of formatting and naming the images includes the following steps: for the extracted images, based on the geometric relationship and layout features of the text blocks within the page of the case document, the original image caption text is detected and determined; the extracted images are formatted and named according to the original image caption text.
[0015] Furthermore, based on the geometric relationship and layout features of text blocks within the page of the image and case document, the native image caption text is detected and determined, specifically including the following steps: For each image, calculate its horizontal overlap rate and vertical distance with each text block within the page; according to preset image caption filtering rules, filter candidate image caption text blocks from the text blocks; from the filtered candidate image caption text blocks, determine the native image caption text of the image; wherein, the image caption filtering rules are configured as follows: filter text blocks whose horizontal overlap rate reaches a first threshold, whose vertical distance is less than a second threshold, and whose font size conforms to preset image caption font features; if the native image caption text of the image cannot be filtered, call the visual big model to generate title text based on the image and the surrounding text content of the image, and use the title text as the name of the image.
[0016] Furthermore, the visual big model is invoked to generate title text based on the image and its surrounding text content. This includes the following steps: constructing the context information of the image, which includes at least some of the surrounding text on the page where the image is located; inputting the image and context information into the visual big model to generate title text; wherein, when invoking the visual big model, interception rules are configured to filter images belonging to a preset invalid type.
[0017] According to another aspect of the present invention, a data extraction apparatus for spatial analysis is provided, comprising: The data extraction module is used to acquire the target site's coordinate text file, spatial point data file, and case document; the benchmark coordinate extraction module is used to extract benchmark coordinates from the coordinate text file; the benchmark coordinate extraction module includes: a coordinate extraction unit, a coordinate sequence construction and scoring unit, and a judgment unit; the coordinate extraction unit is used to extract the first and second coordinate values from the coordinate text file using a regular expression compatible with multiple delimiters; the coordinate sequence construction and scoring unit is used to construct corresponding original and inverted coordinate sequences based on the first and second coordinate values, and to competitively score the original and inverted coordinate sequences using a preset geographical distribution rationality scoring model. The system comprises: a judgment unit, used to determine the mapping relationship between the first and second coordinate values as the reference latitude and reference longitude based on the competitive scoring results, and outputting the reference coordinates; a differential filtering module, used to perform differential filtering on the spatial point data file based on the calculated spherical distance, and obtain a subset of data spatially associated with the target site; wherein, the differential filtering module includes a distance calculation unit, used to calculate the spherical distance between each data point in the spatial point data file and the reference coordinates based on the reference coordinates; and a document parsing module, used to obtain the case documents of the target site, parse the case documents to extract structured text information and images, and format and name the images.
[0018] According to another aspect of the present invention, a computing device is provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the instructions to implement the steps of the data extraction method for spatial analysis as described above.
[0019] According to another aspect of the present invention, a computer-readable storage medium is provided that stores computer instructions which, when executed by a processor, implement the steps of the data extraction method for spatial analysis described above.
[0020] The beneficial effects of this invention are as follows: The data extraction method and apparatus for spatial analysis of this invention fundamentally solves the problem of spatial benchmark distortion through intelligent coordinate calibration; it breaks down the barriers to information fusion in unstructured documents through document topology-preserving extraction and semantic association between text and images; and finally, through differentiated spatial filtering, it achieves precise purification of massive amounts of data for business purposes. The entire method and apparatus form an end-to-end automated preprocessing pipeline from multi-source heterogeneous raw data to a high-quality, structured "information subset" that can directly drive intelligent analysis (such as the generation of large language model reports). This solution significantly improves the efficiency and reliability of the data preparation stage, providing a solid and reliable data foundation for in-depth intelligent analysis in fields such as urban planning and environmental assessment. Attached Figure Description
[0021] The invention can be better understood by describing exemplary embodiments disclosed herein in conjunction with the accompanying drawings, in which: Figure 1 The diagram shown is a schematic flowchart of a data extraction method for spatial analysis according to a first embodiment of the present invention. Figure 2 The diagram shown is a schematic diagram of a program module for a data extraction device for spatial analysis according to a first embodiment of the present invention. Figure 3 The diagram shown is a hardware structure schematic of a computing device according to Embodiment 1 of the present invention. Detailed Implementation
[0022] The following describes specific embodiments of the present invention. It should be noted that, in order to provide a concise description, this specification cannot exhaustively describe all features of the actual embodiments. It should be understood that, in the actual implementation of any embodiment, just as in any engineering or design project, various specific decisions are often made to achieve the developer's specific goals and to meet system-related or business-related constraints, and this can change from one embodiment to another. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this invention, some design, manufacturing, or production modifications based on the technical content disclosed in this invention are merely conventional technical means and should not be construed as insufficient content of this invention.
[0023] Unless otherwise defined, the technical or scientific terms used in the claims and description shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in the patent application description and claims of this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. The terms "an" or "a" and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms "comprising" or "including" and similar terms mean that the element or object preceding "comprising" or "including" encompasses the element or object listed following "comprising" or "including" and its equivalents, and do not exclude other elements or objects. The terms "connected" or "linked" and similar terms are not limited to physical or mechanical connections, nor are they limited to direct or indirect connections.
[0024] Example 1 Please see Figure 1 This embodiment proposes a data extraction method for spatial analysis, including the following steps S0 to S4: S0: Receive the input instruction for the target micro-space archive dataset, obtain the target site's coordinate text file, spatial point data file, and case document, and parse the target case directory; specifically, it includes the following steps S01 to S04.
[0025] S01: Parse the target case directory and verify whether it contains the basic data of the target site; that is, verify whether the input materials are complete in the specified directory. The basic data includes: coordinate text files (e.g., "case point.txt"), spatial point data files (e.g., POI CSV file set containing historical points of interest features, panoramic static image CSV dataset), and case documents (e.g., unstructured PDF case documents).
[0026] In this embodiment, the identification of the same case is achieved through a combination of "directory container binding + runtime parameter binding". A single case directory is specified using `--case-dir`, and this directory name is used as the `case_name`. PDFs, case point .txt files, POI CSV files, and panoramic CSV datasets read within this directory are attributed to the same case by default. Under this case directory, four subdirectories—text / , images / , processed_data / , and summary / —are consistently created and used to store intermediate and result files, thus forming a strong and consistent mapping relationship of "same directory, same case," avoiding cross-case data interference.
[0027] S02: Check if a valid result already exists in the output directory.
[0028] After successful verification, to avoid redundant consumption of deep learning computing power, the system performs physical probe redundancy prevention detection, which includes the following steps: 1) Read the target output directory; 2) Determine if the structured output file already exists and its physical size is greater than the preset threshold (e.g., 100 bytes). If so, determine that the task has been successfully generated and automatically block skipping; otherwise, proceed to the next step. S03: Construct structured subdirectories (including text set directory, image set directory, etc.) for isolated storage of intermediate data.
[0029] S04: Force the environment encoding to be latched as UTF-8. This includes the following steps: 1) Before calling the underlying sub-scripts (such as text extraction, image extraction, etc.), copy the current environment variables using os.environ.copy() and explicitly inject env["PYTHONIOENCODING"]="utf-8".
[0030] 2) By passing the environment variable to the child process via subprocess.run(..., env=env), the Python interpreter is forced to use UTF-8 encoding for cross-process communication at the operating system level, eliminating the risk of pipe truncation caused by the default GBK encoding in Windows.
[0031] 3) Dynamic reconstruction of standard output stream: In the global initialization phase (i.e. at the top of the code file) of all called underlying independent processing scripts (such as extract_pdfs_to_md.py, process_pdf_images.py, process_poi_panorama.py, generate_case_card.py), the system-level API sys.stdout.reconfigure(encoding='utf-8') is called uniformly.
[0032] This call dynamically overrides the encoding protocol of the standard output stream (stdout) at runtime, ensuring that Chinese characters output to the console or written to the log do not trigger a UnicodeEncodeError crash exception.
[0033] 4) Explicit File I / O Locking: Encoding parameters are also forcibly specified in operations involving physical disk writing. For example, when writing Markdown text, call open(..., encoding="utf-8"), and when writing cleaned CSV data, call to_csv(..., encoding="utf-8-sig") (appending a BOM header for Excel compatibility), thereby achieving end-to-end encoded secure locking from inter-process communication to file writing to disk.
[0034] After completing step S0 above, subsequent steps S1 and S2 can be executed sequentially, or steps S1 and S2 can be executed simultaneously.
[0035] S1: Analyze and latch the reference coordinates of the target site.
[0036] In the parsing process, to solve the common problems of "inverted latitude and longitude", "inconsistent separators (mixed use of Chinese and English commas)" and "mixed positive and negative signs" that often occur when manually entering coordinates, this application uses a coordinate adaptive calibration algorithm with heuristic scoring (a regular expression with high robustness) to extract and identify the reference coordinate latitude and longitude, specifically including the following steps S11 to S13: S11: Extract the first coordinate value V1 and the second coordinate value V2 from the coordinate text file using a regular expression compatible with multiple delimiters.
[0037] A robust regular expression (e.g., ([+-]?\d+(?:\.\d+)?)\s) is constructed by reading the coordinate text file using a preset UTF-8 character encoding. [,,]\s ([+-]?\d+(?:\.\d+)?)), scans and matches the entire text, skipping irrelevant text descriptions (such as "case point:"), and accurately extracts two consecutive floating-point values separated by half-width commas "," or full-width commas "," and spaces of arbitrary length. The extracted sequences are recorded as the first coordinate value V1 and the second coordinate value V2, respectively.
[0038] S12: Based on the first coordinate value V1 and the second coordinate value V2, construct the corresponding original coordinate sequence and inverted coordinate sequence, and use a preset geographical distribution rationality scoring model to competitively score the original coordinate sequence and inverted coordinate sequence; specifically including the following steps: 1) Input the first coordinate value V1 as a candidate latitude value (Lat) and the second coordinate value V2 as a candidate longitude value (Lon) into the geographic distribution rationality scoring model to calculate the final score of the original coordinate sequence. ; 2) Input the first coordinate value V1 as a candidate longitude value (Lon) and the second coordinate value V2 as a candidate latitude value (Lat) into the geographic distribution rationality scoring model to calculate the final score of the inverted coordinate sequence. ; The geographical distribution rationality scoring model is configured as follows: for the input coordinate sequence, according to the preset geographical range in which its latitude value (Lat) and longitude value (Lon) fall respectively, the corresponding latitude score and longitude score are assigned, and the latitude score and longitude score are summed to calculate the corresponding final score.
[0039] In this embodiment, if the latitude value (Lat) exceeds Or the longitude value (Lon) exceeds It imposes a very large negative penalty value: If the latitude (Lat) or longitude (Lon) value falls within a high-frequency residential zone (e.g., If the latitude (Lat) or longitude (Lon) value falls within the second-highest frequency range (e.g., ...), the score will be increased by the first weighted value: 2.0; The score will be increased by a second weighting factor: 1.0.
[0040] S13: Based on the results of the competitive scoring, determine the mapping relationship between the first and second coordinate values as the reference latitude and reference longitude, respectively, to output the reference coordinates ( Specifically, it includes the following steps: Compare the final scores of the original coordinate sequence and the inverted coordinate sequence (i.e., compare) and ).
[0041] If the final score of the original coordinate sequence is higher than the final score of the inverted coordinate sequence (i.e.) Then, the first coordinate value is determined to be latitude and the second coordinate value to be longitude (i.e., the reference latitude). Baseline longitude ).
[0042] If the final score of the inverted coordinate sequence is higher than the final score of the original coordinate sequence (i.e.) Then, the first coordinate value is determined to be longitude and the second coordinate value is determined to be latitude (i.e., the reference latitude). Baseline longitude ).
[0043] If the final scores of the original coordinate sequence and the inverted coordinate sequence are the same (i.e.) If the absolute value of the first coordinate is greater than 90 and the absolute value of the second coordinate is less than or equal to 90, then a downgrade check is performed: determine whether the absolute value of the first coordinate is greater than 90 and the absolute value of the second coordinate is less than or equal to 90 (i.e., and If so, the original input format is determined to be misaligned, and a calibration flip is forcibly performed to determine the first coordinate value as longitude and the second coordinate value as latitude; otherwise, it remains unchanged, and the first coordinate value is determined as latitude and the second coordinate value as longitude.
[0044] In steps S0 and S1 of this invention, step S0 establishes a solid starting point for the entire process, while step S1 solves the core problem of coordinate uncertainty. Through catalog verification, redundancy prevention detection, and mandatory UTF-8 environment encoding, the repeatability and stability of the process are ensured. Its core innovation lies in the "coordinate adaptive calibration algorithm" in step S1: it does not pre-determine the latitude and longitude order, but instead extracts numerical pairs (V1, V2) and constructs two candidate sequences, "original" and "inverted." It then uses a scoring model based on prior geographical distribution knowledge (such as residential zone weights) for competitive scoring, with the higher score winning. In case of a tie, a downgraded verification based on the latitude and longitude numerical range is initiated, thereby intelligently outputting highly reliable baseline coordinates (lat, lon). Its beneficial effects are as follows: 1. Robustness of the process: Up-the-line input validation, anti-duplication processing and code latching eliminate common faults caused by environmental differences and repetitive tasks at the system level, ensuring the stable operation of the automated process.
[0045] 2. Intelligent coordinate error correction: The core algorithm creatively solves the fundamental problem of "inverted latitude and longitude values" caused by manual input or differences in data sources, realizing fully automatic and highly reliable conversion from messy text to accurate geographic coordinates, providing an absolutely correct reference origin for all subsequent spatial calculations.
[0046] S2: Parse the case document to extract structured text information.
[0047] Original case documents are typically in PDF format. Because these documents often contain complex text and image combinations, illegal cross-system naming conventions, and significant amounts of whitespace noise, directly inputting them into a language model can lead to context window overflow and misalignment with facts. Therefore, text extraction and structured reorganization are necessary, specifically including the following steps: S21: Perform metadata sniffing and extraction on the case documents. This specifically includes the following steps: S211 to S213: S211: Call pdfplumber to open the PDF in binary stream mode, and prioritize sniffing embedded metadata to extract the title.
[0048] The pdfplumber document parsing library is invoked to securely load and open the target PDF file as a low-level binary stream. Upon successful loading, the system first sniffs out the embedded metadata features of the document; then it retrieves the corresponding document title (i.e., the Title field in the metadata features); if metadata is missing or parsing is abnormal, the system automatically downgrades, using the current file's base name (File Stem) as the initial root node name.
[0049] S212: Perform cross-system illegal character cleanup on names.
[0050] Call the secure file naming filter engine / function to perform illegal character cleanup on the initial root node name, removing characters prohibited by target operating systems such as Windows (e.g., <>: " / \|?). Replace ) with a safe placeholder (underscore _), and truncate any leading or trailing whitespace and decimal points. If the cleaned case title is empty, assign the default safe identifier untitled.
[0051] S213: Detect whether a file with the same name (.md) exists in the target text directory.
[0052] The system checks whether the .md file corresponding to the cleaned target name already exists in the target text set directory. If a file with the same name exists, the system triggers an anti-overwrite spin detection mechanism, which continuously probes available file paths by attaching an auto-incrementing index vector (such as (1), (2)) until a globally unique file mapping path is generated to avoid the risk of overwriting.
[0053] S22: Extract text information page by page from the case file; during extraction, the page objects provided by pdfplumber are used to strictly traverse and slice the document according to the physical page index. Specifically, this includes the following steps: Extract visible characters page by page by calling extract_text(): Call the page.extract_text() interface to peel off and extract the visible character mapping stream from the current physical page page by page.
[0054] To ensure accurate tracing based on page numbers during subsequent multimodal text-image alignment, the physical page number for extracting text information is strictly kept consistent with the original case document. When a physical page is detected to contain only images or tables, resulting in an empty extraction return value, or when the underlying extraction engine throws an exception, the page is not skipped. Instead, a preset placeholder text, "[No extractable text detected on this page]", is automatically pushed into the data slot of the corresponding page number, thus forming a continuous text array with absolute anchor reference value.
[0055] S23: Perform noise compression and structuring processing on the extracted text information. This specifically includes the following steps S231 to S234: S231: Invoke the two-dimensional noise folding operator independently for each page of text.
[0056] The two-dimensional noise folding operator is applied independently to each extracted page of text, specifically including the following steps: 1) Map non-standard carriage return characters (such as \r\n, \r) to the standard newline character \n; 2) Use the first regular expression [ \t]+ to perform horizontal whitespace compression, which collapses multiple consecutive spaces or tabs into a single space; 3) Use the second regular expression \n{3,} to perform vertical compression, which collapses newline characters that appear three or more times in a row into double newline characters (\n\n), thereby filtering out typesetting noise to the maximum extent while preserving the semantic boundaries of the original paragraph.
[0057] S232: Place the names determined in S21 as first-level headings in the header according to a structured paradigm (such as Markdown paradigm), and then concatenate the text of each page in sequence.
[0058] S233: Insert a globally unique separator between text on adjacent physical pages.
[0059] S234: Write to a unique path using UTF-8 encoding, and output a high-density plain text knowledge set.
[0060] The knowledge set output in step S2 is physically a collection of multiple independent .md files, and its organization rules and internal structure are strictly as follows: 1. File organization-level mapping (one .md file corresponds to one PDF document related to a case study): The output is generated according to a 1:1 mapping relationship between the source file and the target file. The number of input PDF files in the current case directory (case_dir) will generate the same number of .md files in the corresponding text subdirectory (text / ). Through the detection in step S213, it can be ensured that even if multiple PDFs under the same case have the same base title, independent and unoverwritten files (such as design specification.md, design specification (1).md) will be generated.
[0061] 2. Strict internal topological structure of the file: Each output .md file strictly follows the system's built "Markdown topology tree" format, containing three levels from top to bottom: 1) Global header: The first line of the file is fixed as the name of the extracted and cleaned root node as a first-level heading, in the format #{base_title} (e.g., #Yongqingfang Urban Renewal Design Description).
[0062] 2) Page text block: Subsequently, the compressed plain text of each page is written sequentially. If the system detects that a page is empty or consists entirely of images (i.e., no character stream), a fixed placeholder "[No extractable text detected on this page]" will be forcibly inserted to maintain absolute page number anchor alignment.
[0063] 3) Dynamic Page Breaker: In multi-page PDF documents, the system dynamically inserts a three-line structure (blank line + --- + blank line) as a page break anchor between text blocks on two adjacent physical pages; if the original PDF is a single page (such as a long screenshot of a webpage), this breaker is not inserted. In step S2 of this invention, a method specifically designed for processing unstructured PDF documents is employed to achieve faithful, structured text extraction. The process first determines the document's unique identifier through metadata sniffing and secure cleaning (S21). The core of this process lies in S22, which strictly traverses the physical page numbers, inserting placeholders even on pages without text to force consistency with the source document's page number topology. Subsequently, S23 uses a "two-dimensional noise folding operator" to compress layout whitespace and line breaks, and reorganizes the text according to a preset Markdown paradigm (first-level headings, page breaks ---), ultimately outputting a structured knowledge set. Its beneficial effects are as follows: 1. Page number topology fidelity: By forcibly traversing all physical pages and processing empty pages, the extracted text block sequence forms a strict and traceable mapping relationship with the page layout and image position of the original document, laying a solid foundation for subsequent text and image alignment.
[0064] 2. Deep Cleaning and Structured Output: Multi-level regular expression cleaning significantly improves the text signal-to-noise ratio and reorganizes it into a structured format (such as Markdown) with clear hierarchy (headings, pagination). This greatly optimizes the readability and understandability of the text for downstream Large Language Models (LLMs) and avoids semantic understanding bias caused by format noise.
[0065] S3: Parse the images in the case document and format and name the images.
[0066] Directly formatting and naming isolated images can easily overlook their typographical context within the original text, increasing the risk of semantic shifts or misnaming. Therefore, a pipeline combining layout feature detection and a multimodal large-scale model is needed for extraction and naming, specifically including the following steps S31 to S34: S31: Extract images from the case document; specifically including the following steps S311 to S313: S311: Call PyMuPDF to parse the original structure dictionary of the page and separate the text blocks from the image blocks.
[0067] The document parsing engine (PyMuPDF) is invoked to obtain the raw structure dictionary (rawdict) of the current physical page. The block objects in the dictionary are traversed to separate the text block array (Type=0) and the image block array (Type=1).
[0068] S312: Obtain the image bounding box, calculate the area, and remove layout noise that is smaller than the preset effective threshold.
[0069] For each extracted image region, its physical bounding box (denoted as Rect_img) is obtained, and the physical area of the rectangle is calculated. If the area is less than a preset effective threshold (e.g., 20,000 square pixels), the system identifies it as layout noise (such as separator lines or micro-decorations) and removes it.
[0070] S313: For image frames that meet the valid threshold, call the rendering interface (get_pixmap), perform region cropping at a preset resolution (e.g., 150 DPI), and convert it into a PNG byte stream in memory.
[0071] S32: Perform image annotation sniffing on the extracted image.
[0072] For the extracted images, based on the geometric relationship and layout features of the text blocks within the page of the case document, the original image caption text is detected and determined; the extracted images are then formatted and named according to the original image caption text. Specifically, this includes the following steps S321 to S324: S321: For each image, calculate its horizontal overlap and vertical distance with each text block on the page.
[0073] Traverse the valid text blocks within the page (denoted as ) ), calculate its with The two-dimensional Cartesian shortest distance between (where dx and dy are the horizontal and vertical spacing between the bounding boxes).
[0074] S322: According to the preset caption filtering rules, select candidate caption text blocks from the text blocks; wherein, the caption filtering rules are configured to: select text blocks whose horizontal overlap rate reaches the first threshold, whose vertical distance is less than the second threshold, and whose font size conforms to the preset caption font characteristics.
[0075] In this embodiment, the vertical distances calculated in step S321 are sorted in ascending order, and the nearest several text blocks are selected and spliced together to form the spatial enhancement context. The contents of the selected text blocks with the nearest vertical distance are spliced together to form the 'spatial enhancement context' text of the image, and truncated to the maximum number of characters (e.g., 400 characters) as candidate caption text.
[0076] S323: From the selected candidate image caption text blocks, filter potential native image caption text and determine the native image caption text for the image. This specifically includes the following steps: 1. Filter the candidate figure annotation text blocks. Among them, potential native caption texts that meet all of the following conditions are filtered from the candidate caption text blocks: 1) The horizontal overlap with the image frame reaches 35% or more; 2) Located within a vertical distance of 90pt directly above or below the image; 3) The text length shall not exceed 60 characters; 4) The average font size (e.g., ≤12.5pt) or minimum font size (e.g., ≤11.5pt) conforms to the typical caption layout characteristics.
[0077] The specific execution steps are as follows: 1) The text block structure is obtained by using page.get_text("rawdict"); each text block tb contains lines -> spans, and each span has its own font size field size.
[0078] 2) In font_stats(tb), iterate through all span.size values of the text block, collect the values into the sizes list, and then directly calculate: min(sizes) as the minimum font size and sum(sizes) / len(sizes) as the average font size.
[0079] 3) In the selection of candidate image annotation blocks, use the condition avg≤12.5 or min≤11.5 to perform hard threshold filtering.
[0080] 4) If a potential native image caption text is selected, the image is named with that potential native image caption text, and the process proceeds to step S34; if multiple potential native image caption texts exist, the process proceeds to step S324; if no potential native image caption text is selected, the process proceeds to step S33.
[0081] S324: Determine the optimal original image caption text through weighted scoring and format the image name.
[0082] Calculate the weighted score for each potential native caption text; in, This refers to the horizontal overlap rate. Assign vertical position weights (1.0 for the bottom and 0.6 for the top). Vertical distance; Bonus points are awarded for small fonts (1.5 points for average font size ≤ 11.0pt, otherwise 0.5 points).
[0083] Take the text corresponding to the highest Score value as the original caption text of the image, and proceed to step S34 to format and name the image.
[0084] S33: Invoke the large visual model to generate title text based on the image and its surrounding text content, and use the title text as the image's name. Specifically, this includes the following steps S331 to S333: S331: Filter invalid images; When calling the large visual model, interception rules are configured to filter images belonging to a preset invalid type. Specifically, this includes the following steps: 1) Convert the image byte stream to Base64 format and extract the base name (File Stem) and current page number of the current PDF file.
[0085] 2) Constrain the visual big language model to generate a title without punctuation that does not exceed the preset number of characters (25 characters) by using system prompt words; at the same time, set interception rules in the instructions, requiring the model to return a specific string (SKIP) when it recognizes invalid visual assets (such as emojis, plain text screenshots, QR codes, etc.).
[0086] When the program captures this return value, it physically executes the logic to discard the image.
[0087] S332: Use the large visual model to generate titles, specifically including: Construct contextual information for the image, including at least some surrounding text on the page where the image is located; input the image and contextual information into the visual big model to generate the title text.
[0088] The visual model consists of a primary visual model (qwen-vl-max) and a backup visual model (qwen-vl-plus). During the request process, if the primary visual model throws an exception or refuses to respond, the system first switches to the backup visual model for retry. If the API client is unavailable, the network times out, or the model fails to return valid content, the system triggers a fallback mechanism, reverting to using the first line of the candidate image caption text block selected in step S322 as the default title for the image.
[0089] S34: Format and name the extracted images.
[0090] For the extracted original image caption text, title text generated by the large visual model or backup visual model, perform illegal character filtering and length truncation, and persistently store the image in the preset output directory according to the structured naming specification of "[file base name] - [cleaned title] - p[page number] - [page number].png", thereby providing visual assets with a clear traceability path for subsequent steps.
[0091] The specific cleaning rules for the "cleaned titles" are as follows: After obtaining the original image caption text or the title text generated by the visual model, the following cleaning steps are performed before formatting and naming the extracted images: 1) Use regular expression substitution to remove newline characters (`\r`, `...`). `) collapses into a space; 2) Call the core `sanitize_filename` engine to block special characters prohibited by the Windows file system (such as `\ / :`). The spaces " < > |` are uniformly replaced with safe placeholders (spaces or underscores); then, the regular expression `re.sub(r"\s+", " ", name).strip()` is executed to merge multiple consecutive whitespace characters into a single space, and remove any residual spaces and punctuation marks (such as periods and exclamation marks at the end) at the beginning and end. 3) To prevent system errors caused by excessively long paths, force truncation to the maximum length (e.g., 60 characters). If the truncated path ends with a space, execute `rstrip()` again.
[0092] The rules for generating "page serial numbers" are as follows: The image's "intra-page number" is generated based on the natural parsing order of object blocks in the underlying data dictionary (`rawdict`) of the current physical page by the parsing engine (PyMuPDF). Since PDF rendering engines typically generate blocks according to the z-order (drawing stacking order) of objects or the top-down physical flow layout order, this number has a stable spatial relative position characteristic within the page.
[0093] In step S3 of this invention, images are automatically extracted from documents and given semantic names. First, images are accurately extracted and filtered (S31). The core naming employs a two-step hybrid intelligent strategy: First, geometric and layout sniffing (S32) intelligently locates and extracts the "original caption" as the best name by calculating features such as the horizontal overlap rate, vertical distance, and font size of the image and surrounding text blocks. Second, a cross-modal visual model is used as a fallback (S33). When sniffing fails, a large visual model (VLMM) is invoked to generate a descriptive title by combining the image content and its surrounding text. After cleaning, all names are stored according to the specification [file base name]-[cleaned title]-p[page number]-[page sequence number].png. Its beneficial effects are as follows: 1. Automated image-text semantic association: It pioneered a hybrid strategy of "geometric sniffing as the main method and AI generation as the auxiliary method", which overcame the technical challenge of automatically and accurately associating document images with their original contextual semantics (captions), so that images remain comprehensible even after being separated from the document.
[0094] 2. Constructing traceable visual assets: The generated image files have semantically rich names, and the names embed source document and page number information, making them searchable and understandable structured data units, which greatly promotes the fusion and analysis of multimodal data.
[0095] S4: Based on the reference coordinates, calculate the spherical distance between each data point in the spatial point data file and the reference coordinates; based on the spherical distance, perform differential filtering related to data type on each data point in the spatial point data file to obtain a data subset spatially associated with the target site. Specifically, this includes the following steps S41 to S43: S41: Dynamically sniff the coordinate fields in the spatial point data file. This specifically includes the following steps S411 to S412: S411: Construct a polling decoding sequence containing UTF-8-SIG, UTF-8, and GBK, perform a secure read with a backoff mechanism, and read the POI CSV file set and the panoramic static image CSV dataset respectively.
[0096] The POI CSV file set includes several POI raw data tables; the panoramic static image CSV dataset includes several panoramic raw data tables.
[0097] S412: Perform dynamic sniffing of the spatial coordinate field on the read data frame.
[0098] Specifically, the read data frames point to two types of raw data tables: the POI raw data table and the panoramic raw data table. The data frames include DataFrames formed by reading the POI raw CSV and the panoramic raw CSV respectively. For the data frames of the POI raw data table, composite coordinate splitting and column name mapping reconstruction are performed; for the data frames of the panoramic raw data table, priority coordinate column selection and normalization mapping are performed.
[0099] In this embodiment, the specific steps include: The system checks if a coordinate composite column exists. If it does, it performs string cleaning (removing leading and trailing whitespace and double quote characters) and splits the column into longitude and latitude feature columns according to a specific delimiter. If the coordinate composite column is missing, it starts a column name mapping matching engine, traverses and matches the preset longitude candidate set (such as "longitude", "lon", "lng") and latitude candidate set (such as "latitude", "lat"), and dynamically reconstructs the absolute longitude and latitude data column, thereby solving the compatibility problem of non-standard headers in multi-source data tables.
[0100] S42: Calculate the spherical distance between each data point in the spatial point data file and the reference coordinates. This specifically includes the following steps S421 to S422: S421: Extract the reference coordinates output in step S13 and convert all coordinates to radians.
[0101] To address the computational bottleneck caused by massive urban spatial data points, this invention abandons the inefficient line-by-line traversal logic and instead calls the underlying numerical calculation engine to perform vectorized spherical distance calculations. Therefore, all extracted latitude and longitude coordinates are first converted from degrees to radians.
[0102] S422: Performs vectorized matrix operations based on Havesing's formula to calculate the spherical distance from each data point to the reference coordinates in batches.
[0103] Matrix operations are performed based on the Havesing formula to calculate the difference in latitude and radians between two points. dlat Difference between longitude and radian dlon The distance model calculation formula is as follows: spherical distance ; in: ; ; The base latitude in radians. The latitude and radian values of the data points; A numeric clipping function that sets clipping boundaries (0.0 to 1.0) to prevent floating-point overflow; This is a geophysical radius parameter (e.g., 6371000.0 meters).
[0104] The above model outputs a sequence of distances from the target site to surrounding data points in the real spherical space.
[0105] In step S422, the original data type of the distance sequence in the computation layer is a NumPy ndarray (float64) (returned by haversine_vec(...)), which is then encapsulated as a Pandas Series and written to the data frame df["distance"]. Since the program first initializes with distances=pd.Series(np.nan,index=df.index) and then backfills the calculation results with the same index mask, before entering the filtering / sorting stage, the distance and the original CSV row records are strictly one-to-one corresponding by index (rows without coordinates correspond to NaN).
[0106] S43: Perform differential filtering on the spatial point data files based on data type to obtain a subset of data spatially associated with the target site. Specifically, this includes the following steps S431 to S432: S431: Add the distance sequence as a new dimension and stitch it into the corresponding original data (POI original data table and panorama original data table).
[0107] S432: Perform differential filtering associated with data type, specifically including the following steps: Identify the data type of each point in the spatial location data file, including facility point data and environmental image acquisition point data.
[0108] For data points whose data type is facility point data, the first filtering strategy is executed: the calculated spherical distance is compared with the preset radius threshold, and data points whose distance is less than or equal to the radius threshold are retained to form the first data subset.
[0109] In this embodiment, for a set of Points of Interest (POIs), a spatial buffer mask with a specific radius (500 meters) is constructed to physically remove redundant data containing null values and exceeding the distance threshold, thereby realizing the quantitative extraction of the surrounding core supply capabilities.
[0110] For data points whose data type is environmental image acquisition point data, a second filtering strategy is executed: sort them in ascending order according to the calculated spherical distance, and retain the data points in the first N positions to form a second data subset.
[0111] In this embodiment, for panoramic static image sets, backup high-precision coordinate columns (such as "longitude_0" and "latitude_0") are detected and applied first. Then, they are strictly sorted globally in ascending order according to spherical distance values, and Top-N truncation filtering is performed according to a preset quantity limit (such as the first 50 images) to ensure that the street view samples subsequently fed into the visual model are geographically closest to the core renovation area. Finally, all cleaned and truncated spatial datasets are output to the structured workspace in a unified encoding format (UTF-8-SIG) with a signature header.
[0112] In step S4 of this invention, the target site is precisely correlated and filtered with massive external spatial data. First, through polling decoding and dynamic field sniffing (S41), multi-source CSV data is intelligently compatible, and standard latitude and longitude fields are reconstructed, resolving the compatibility issue caused by non-standard table headers. Next, using the reference coordinates output in S1, spherical distances are efficiently calculated through vectorized matrix operations (S42). Finally, differentiated filtering is performed (S43): a radius threshold method (e.g., 500 meters) is used for "Facility Points" (POIs) to reflect service coverage logic; a nearest neighbor ranking method (e.g., Top 50) is used for "Environmental Image Acquisition Points" (panoramic images) to focus on the most geographically representative samples. Its beneficial effects are as follows: 1. Highly efficient and compatible spatial calculation: The combination of dynamic field sniffing and vectorized calculation ensures compatibility with complex data sources while enabling fast and accurate calculation of distances to massive points.
[0113] 2. Data purification for analysis scenarios: Abandoning the "one-size-fits-all" screening, the optimal strategy is adopted according to the data type (static facilities vs. dynamic collection points) so that the output data subset (first and second data subsets) directly matches the specific business analysis scenario (such as facility assessment and visual analysis), realizing high-quality data purification from "spatial proximity" to "business relevance".
[0114] After completing steps S1 to S4, the system obtains core data assets for subsequent in-depth analysis: a subset of data spatially associated with the target site (from S43), a structured text knowledge set (from S234), and semantically named and traceable image assets (from S34). Subsequently, the system automatically integrates this cleaned, filtered, named, and structured multimodal data to form a unified data context. This context is directly input into a Large Language Model (LLM), which, through predefined instruction templates, drives the LLM to generate a comprehensive and structured analysis report (such as current status assessment and planning recommendations) about the target site, thus achieving full-process automation from raw, messy data to final decision support information.
[0115] Please continue reading. Figure 2 This invention illustrates a data extraction device for spatial analysis. In this embodiment, the data extraction device for spatial analysis may include or be divided into one or more program modules. One or more program modules are stored in a storage medium and executed by one or more processors to complete the invention and implement the aforementioned data extraction method for spatial analysis. The program module referred to in this invention is a series of computer program instruction segments capable of performing a specific function, and is more suitable than the program itself for describing the execution process of a data extraction device for spatial analysis in a storage medium. The following description will specifically introduce the functions of each program module in this embodiment: The data extraction module is used to obtain the target site's coordinate text file, spatial point data file, and case documents.
[0116] The baseline coordinate extraction module is used to extract baseline coordinates from a coordinate text file.
[0117] The benchmark coordinate extraction module specifically includes: a coordinate extraction unit, a coordinate sequence construction and scoring unit, and a judgment unit.
[0118] The coordinate extraction unit is used to extract the first and second coordinate values from a coordinate text file using a regular expression compatible with multiple delimiters.
[0119] The coordinate sequence construction and scoring unit is used to construct the corresponding original coordinate sequence and inverted coordinate sequence based on the first coordinate value and the second coordinate value, and to competitively score the original coordinate sequence and inverted coordinate sequence through a preset geographical distribution rationality scoring model.
[0120] The judgment unit is used to determine the mapping relationship between the first coordinate value and the second coordinate value as the reference latitude and reference longitude, respectively, based on the results of the competitive scoring, so as to output the reference coordinates.
[0121] The differential filtering module is used to perform differential filtering on each data point in the spatial point data file based on the calculated spherical distance, and obtain a subset of data that is spatially associated with the target site.
[0122] The differential filtering module specifically includes: a distance calculation unit, a type identification unit, a first filtering unit, and a second filtering unit.
[0123] The distance calculation unit is used to calculate the spherical distance between each data point in the spatial point data file and the reference coordinates, based on the reference coordinates.
[0124] The type identification unit is used to identify the data type of each point in the spatial point data file. The data types include facility point data and environmental image acquisition point data. The first filtering unit is used to execute a first filtering strategy for data points whose data type is facility point data: compare the calculated spherical distance with a preset radius threshold, and retain data points whose distance is less than or equal to the radius threshold to form a first data subset; The second filtering unit is used to execute a second filtering strategy for data points whose data type is environmental image acquisition point data: sort them in ascending order according to the calculated spherical distance, and retain the data points in the first N positions to form a second data subset.
[0125] The document parsing module is used to obtain case documents for the target site and parse the case documents to extract structured text information and images.
[0126] The document parsing module specifically includes: a document structuring processing unit and a text-image collaborative alignment unit.
[0127] The document structuring unit is used to parse the case documents to extract structured text information.
[0128] The image-text collaborative alignment unit is used to parse images in the case document and format and name the images.
[0129] Furthermore, it also includes a report generation module, which integrates a subset of data spatially associated with the target site, structured text information, and named images, and inputs them into a large language model to generate an analysis report about the target site.
[0130] This embodiment also provides a computing device, such as a smartphone, tablet computer, laptop computer, desktop computer, rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple servers) capable of executing programs. The computing device 20 in this embodiment includes, but is not limited to, a memory 21 and a processor 22 that can communicate with each other via a system bus. Figure 3 As shown. It should be noted that, Figure 3 Only a computing device 20 with components 21-22 is shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0131] In this embodiment, the memory 21 (i.e., the readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 21 may be an internal storage unit of the computing device 20, such as the hard disk or memory of the computing device 20. In other embodiments, the memory 21 may also be an external storage device of the computing device 20, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computing device 20. Of course, the memory 21 may include both the internal storage unit and the external storage device of the computing device 20. In this embodiment, the memory 21 is typically used to store the operating system and various application software installed on the computing device 20, such as the program code of a data extraction device for spatial analysis in Embodiment 1. In addition, the memory 21 can also be used to temporarily store various types of data that have been output or will be output.
[0132] In some embodiments, processor 22 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor 22 is typically used to control the overall operation of computing device 20. In this embodiment, processor 22 is used to run program code stored in memory 21 or process data, for example, to run a data extraction device for spatial analysis to implement a data extraction method for spatial analysis according to Embodiment 1.
[0133] This embodiment also provides a computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, server, app store, etc., which stores a computer program. When the program is executed by a processor, it implements the corresponding function. The computer-readable storage medium of this embodiment is used to store a data extraction device for spatial analysis, and when executed by a processor, it implements a data extraction method for spatial analysis according to Embodiment 1.
[0134] In summary, according to the exemplary embodiments, the data extraction method and apparatus for spatial analysis of the present invention fundamentally solves the problem of spatial benchmark disorder through intelligent coordinate calibration in step S1; it breaks down the barriers to the fusion of unstructured document information through document topology-fidelity extraction in step S2 and semantic association of text and images in step S3; and finally, through differentiated spatial filtering in step S4, it achieves precise purification of massive data for business purposes. The entire method and apparatus form an end-to-end automated preprocessing pipeline from multi-source heterogeneous raw data to a high-quality, structured "information subset" that can directly drive intelligent analysis (such as the generation of large language model reports). This solution significantly improves the efficiency and reliability of the data preparation stage, providing a solid and reliable data foundation for in-depth intelligent analysis in fields such as urban planning and environmental assessment.
[0135] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0136] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0137] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable medium, and when executed, it includes one or a combination of the steps of the method embodiments.
[0138] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0139] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0140] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A data extraction method for spatial analysis, characterized in that, Includes the following steps: Obtain the coordinate text file and spatial point data file of the target site; The first and second coordinate values are extracted from the coordinate text file using a regular expression compatible with multiple delimiters; Based on the first coordinate value and the second coordinate value, a corresponding original coordinate sequence and an inverted coordinate sequence are constructed, and the original coordinate sequence and the inverted coordinate sequence are competitively scored through a preset geographical distribution rationality scoring model. Based on the results of the competitive scoring, the first coordinate value and the second coordinate value are determined as the mapping relationship between the reference latitude and the reference longitude, respectively, so as to output the reference coordinates; Based on the reference coordinates, calculate the spherical distance between each data point in the spatial point data file and the reference coordinates; Based on the spherical distance, a differential filtering process associated with the data type is performed on each data point in the spatial point data file to obtain a data subset spatially associated with the target site.
2. The data extraction method for spatial analysis according to claim 1, characterized in that, The process of competitively scoring the original coordinate sequence and the inverted coordinate sequence using a preset geographical distribution rationality scoring model specifically includes the following steps: Using the first coordinate value as a latitude candidate value and the second coordinate value as a longitude candidate value, input them into the geographical distribution rationality scoring model to calculate the final score of the original coordinate sequence; Using the first coordinate value as a candidate longitude value and the second coordinate value as a candidate latitude value, input them into the geographical distribution rationality scoring model to calculate the final score of the inverted coordinate sequence; The geographical distribution rationality scoring model is configured as follows: for the input coordinate sequence, according to the preset geographical range in which its latitude and longitude values fall, a corresponding latitude score and a longitude score are assigned, and the latitude score and longitude score are summed to calculate the corresponding final score.
3. The data extraction method for spatial analysis according to claim 2, characterized in that, The step of determining the mapping relationship between the first coordinate value and the second coordinate value as the reference latitude and reference longitude based on the competitive scoring results specifically includes the following steps: Compare the final scores of the original coordinate sequence with those of the inverted coordinate sequence; If the final score of the original coordinate sequence is higher than the final score of the inverted coordinate sequence, then the first coordinate value is determined to be latitude and the second coordinate value to be longitude. If the final score of the inverted coordinate sequence is higher than the final score of the original coordinate sequence, then the first coordinate value is determined to be longitude and the second coordinate value is determined to be latitude. If the final scores of the original coordinate sequence and the inverted coordinate sequence are the same, then a downgrade check is performed: determine whether the absolute value of the first coordinate value is greater than 90 and the absolute value of the second coordinate value is less than or equal to 90; if so, determine that the first coordinate value is longitude and the second coordinate value is latitude; otherwise, determine that the first coordinate value is latitude and the second coordinate value is longitude.
4. The data extraction method for spatial analysis according to claim 1, characterized in that, The differential filtering process associated with data type specifically includes the following steps: Identify the data type of each point in the spatial point data file, whereby the data types include facility point data and environmental image acquisition point data; For data points whose data type is facility point data, the first filtering strategy is executed: the calculated spherical distance is compared with a preset radius threshold, and data points whose distance is less than or equal to the radius threshold are retained to form a first data subset; For data points whose data type is environmental image acquisition point data, a second filtering strategy is executed: sort them in ascending order according to the calculated spherical distance, and retain the data points in the first N positions to form a second data subset.
5. A data extraction method for spatial analysis according to claim 1, characterized in that, It also includes the following steps: Obtain the case documents for the target site; The case document is parsed to extract structured text information and images, and the images are formatted and named. Integrate the data subset associated with the target site space, the structured text information, and the named image; The process of formatting and naming the image specifically includes the following steps: For the extracted images, based on the geometric relationship and layout features between the images and the text blocks within the page of the case document, the original image caption text is detected and determined; The extracted images are formatted and named according to the original image caption text.
6. A data extraction method for spatial analysis according to claim 5, characterized in that, The process of detecting and determining the original image caption text based on the geometric relationship and layout features of the text blocks within the page of the image and the case document specifically includes the following steps: For each image, calculate its horizontal overlap and vertical distance with each text block on the page; Candidate caption text blocks are selected from the text blocks according to preset caption filtering rules; From the selected candidate image caption text blocks, determine the original image caption text of the image; The caption filtering rules are configured to: filter out text blocks whose horizontal overlap rate reaches a first threshold, whose vertical distance is less than a second threshold, and whose font size conforms to the preset caption font characteristics; If the original caption text of the image cannot be found, the visual big model is invoked to generate title text based on the image and the surrounding text content, and the title text is used as the name of the image.
7. A data extraction method for spatial analysis according to claim 6, characterized in that, The process of calling the large visual model to generate title text based on the image and its surrounding text content includes the following steps: Construct contextual information for the image, wherein the contextual information includes at least some of the surrounding text of the page where the image is located; The image and the context information are input into the large visual model to generate the title text; When the large visual model is invoked, interception rules are configured to filter images belonging to a preset invalid type.
8. A data extraction apparatus for spatial analysis, employing the data extraction method for spatial analysis as described in any one of claims 1 to 7, characterized in that, include: The data extraction module is used to obtain the coordinate text file, spatial point data file, and case document of the target site; A reference coordinate extraction module is used to extract reference coordinates from the coordinate text file; wherein, the reference coordinate extraction module includes: a coordinate extraction unit, a coordinate sequence construction and scoring unit, and a judgment unit; The coordinate extraction unit is used to extract the first coordinate value and the second coordinate value from the coordinate text file using a regular expression compatible with multiple delimiters; The coordinate sequence construction and scoring unit is used to construct corresponding original coordinate sequences and inverted coordinate sequences based on the first coordinate value and the second coordinate value, and to competitively score the original coordinate sequences and inverted coordinate sequences through a preset geographical distribution rationality scoring model. The determination unit is used to determine the mapping relationship between the first coordinate value and the second coordinate value as the reference latitude and reference longitude respectively based on the result of the competitive scoring, so as to output the reference coordinates; The differential filtering module is used to perform differential filtering on each data point in the spatial point data file based on the calculated spherical distance, and obtain a subset of data associated with the target site space. The differential filtering module includes a distance calculation unit, which is used to calculate the spherical distance between each data point in the spatial point data file and the reference coordinates based on the reference coordinates. The document parsing module is used to obtain case documents of the target site, parse the case documents to extract structured text information and images, and format and name the images.
9. A computing device, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the instructions, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing computer instructions, characterized in that, When executed by the processor, this instruction implements the steps of the method according to any one of claims 1 to 7.