A method for identifying land and ocean based on meteorological NetCDF format data
By using meteorological NetCDF format data, the problem of low computing efficiency in identifying land and oceans in the prior art is solved, and more efficient data processing and computing speed is achieved.
Patent Information
- Application Number
- CN202411536276.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-10-31
AI Technical Summary
In the prior art, when identifying land and oceans, computing efficiency and speed cannot meet the current requirements of deep learning algorithms and big data computing.
Meteorological NetCDF format data is used to generate terrestrial data files in NetCDF format, including establishing a latitude and longitude network, using the global_land_mask library to determine land locations, converting data types, creating NetCDF files and dimensions, assigning values and saving data.
It effectively reduces the running time of data reading and judgment, improves the efficiency of large-scale data calculation, and can generate files of different information and precision according to needs, and the data generation and storage methods are flexible.
Smart Images

Figure CN119046397B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of land identification using meteorological NetCDF format data, and in particular relates to a method for identifying land and ocean based on meteorological NetCDF format data. Background Art
[0002] Accurately identifying the sea and land is the basis for ships to sail at sea, especially in navigation and positioning, ship collision avoidance, geographic information systems, etc. For example, if the ship's navigation system cannot accurately distinguish between land and sea, it may lead to errors in route planning and increase the risk of grounding.
[0003] At present, the main methods for identifying land are: identifying shape files, remote sensing identification, geographic information system (GIS) software, online interface identification or some development languages with built-in function libraries, etc. These methods can well determine land and ocean, but the coordinates of each point on the route need to be determined and the higher the accuracy requirement, the greater the amount of calculation. With the research on deep learning algorithms and big data, the requirements for computing efficiency and computing speed are getting higher and higher. At present, the efficiency of these methods in determining land can no longer meet the current computing requirements. Therefore, the present invention proposes a method for identifying land using meteorological NetCDF format data. Summary of the invention
[0004] In view of this, the present invention aims to propose a method for identifying land and ocean based on meteorological NetCDF format data to solve at least one problem existing in the above-mentioned prior art.
[0005] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0006] A method for identifying land and ocean based on meteorological NetCDF format data includes the following steps:
[0007] S1. Generate land data file in NetCDF format;
[0008] S2, reading the file in step S1;
[0009] In step S1, a land data file in NetCDF format is generated, including:
[0010] S11. Establish a longitude and latitude network;
[0011] S12. Use the global_land_mask library to determine which points are land and perform data type conversion; S13. Create NetCDF files and dimensions and create variables and assign values;
[0012] S14, generating an array of equally spaced values within a specified range;
[0013] S15. Save data.
[0014] Further, in step S1, the land data file in NetCDF format includes a file organization and a data model, the file organization includes groups and subgroups, and the data model includes dimensions, variables, and attributes.
[0015] Furthermore, in step S11, a longitude and latitude network is established, including:
[0016] Set the latitude and longitude range and resolution, calculate the number of longitude and latitude points, use the numpy.linspace function to generate equally spaced points within the specified range, and then create an array of land cover data: The landcover array is initialized to 0, indicating the ocean.
[0017] Furthermore, in step S12, the global_land_mask library is used to determine which points are land and perform data type conversion, including:
[0018] Use the globe.is_ocean function of the global_land_mask library to determine which points are land, and set the corresponding landcover array elements to 1;
[0019] Then data type conversion: Convert the data type of the landcover array to np.uint8, which is used to store Boolean values 0 or 1.
[0020] Furthermore, in step S13, a NetCDF file and dimension are created and variables are created and assigned values, including:
[0021] Create NetCDF file and dimensions and create variables and assign values: Create variables for latitude and longitude and fill them with values generated by numpy.linspace;
[0022] Create a landcover variable and use 'u1' as the data type, which represents an unsigned 1-byte integer and is used to store Boolean values.
[0023] Finally save the data to a NetCDF file.
[0024] Further, in step S14, generating an array of equally spaced values within a specified range includes: using the numpy.linspace function in Python to generate an array of equally spaced values within a specified range;
[0025] Use the np.zeros function to create an array initialized to 0 to initialize the land cover data, where 0 represents the ocean and 1 represents the land;
[0026] Use the globe.is_ocean function to determine whether a given latitude and longitude point is an ocean.
[0027] Furthermore, in step S15, the data format is saved as np.uint8.
[0028] Furthermore, in step S2, the file reading method includes:
[0029] S21, read the NetCDF data file, convert the data into BOOL type data and store it in the container;
[0030] S22, input the longitude and latitude information to be queried, and find the position of the point in the BOOL container;
[0031] S23, pass the position i to the BOOL container, and return the result in the BOOL container;
[0032] S24, determining whether the information of all points has been queried;
[0033] S25. The query ends and the query results of all coordinate points are returned.
[0034] Furthermore, in step S22, the search method is as shown in formula (1):
[0035] i=round((lon-minLon) / stepLon)+round((lat-minLat) / stepLat)×(360 / stepLon)(1); wherein i represents the position index of the calculated coordinate in the array, lon represents the latitude of the input coordinate, ranging from [-180,180], lat represents the longitude of the input coordinate, ranging from [-90,90], stepLon represents the resolution of latitude, stepLat represents the resolution of longitude, and the round() function is a rounding function.
[0036] Compared with the prior art, the method for identifying land and ocean based on meteorological NetCDF format data described in the present invention has the following advantages:
[0037] The method for identifying land and ocean based on meteorological NetCDF format data described in the present invention can effectively reduce the running time when reading and judging data, and can significantly improve the program running efficiency when performing large-scale data calculation operations. The present invention uses the NetCDF data format to store land and ocean data, and can generate files containing different information and precision as needed, and the data generation and storage method is flexible. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0039] Figure 1 A schematic diagram of the NetCDF file structure according to an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of the method flow of the embodiment of the present invention;
[0041] Figure 3 This is a schematic diagram of the consumption time comparison according to an embodiment of the present invention;
[0042] Figure 4 A schematic diagram of the difference rate of operating results according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0044] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and the like are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first", "second", and the like may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.
[0045] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood by specific circumstances.
[0046] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0047] like Figures 1 to 4 As shown, a method for identifying land and ocean based on meteorological NetCDF format data includes the following steps:
[0048] 1. Generate land data file
[0049] The generated land data file is NC file, the full name is Network Common Data Format, also known as NetCDF file, which is the network common data format. This file was originally used for storing meteorological data, and has now evolved into a file generation format for many data acquisition software. The file structure is as follows Figure 1 shown.
[0050] NetCDF data has the following advantages:
[0051] 1) NetCDF has good format flexibility and can support various types of data.
[0052] 2) NetCDF has highly efficient I / O performance and can use some faster algorithms to improve efficiency.
[0053] 3) NetCDF file reading and writing are thread-safe and can be safely accessed by multi-threaded programs.
[0054] 4) NetCDF provides support for multiple languages, such as C, C++, Fortran, Python, R and other languages can use NetCDF's API interface to access NetCDF files.
[0055] 5) NetCDF allows multiple variables to be organized in one file, which can be accessed by multiple applications simultaneously, and these variables can be associated with each other.
[0056] Based on the characteristics of NetCDF files, the present invention considers storing land attributes in this format to facilitate data reading efficiency and program multi-threaded processing upgrade operations.
[0057] 2. Generate land data files in NetCDF format. The design process is as follows: Figure 2 shown.
[0058] 1) First set the latitude and longitude range and resolution, then calculate the number of longitude and latitude points. Use the numpy.linspace function to generate equally spaced points within the specified range and then create an array of land cover data: The landcover array is initialized to 0, indicating the ocean.
[0059] 2) Use the globe.is_ocean function of the global_land_mask library to determine which points are land and set the corresponding landcover array elements to 1. Then data type conversion: Convert the data type of the landcover array to np.uint8, which is an unsigned 8-bit integer type used to store Boolean values of 0 or 1.
[0060] 3) Create NetCDF file and dimensions and create variables and assign values: Create variables for latitude and longitude and fill them with values generated by numpy.linspace. Create landcover variable and use 'u1' as data type, which represents unsigned 1-byte integer, used to store Boolean values. Finally, save the data to NetCDF file.
[0061] 4) The numpy.linspace function in Python can generate an array of equally spaced values within a specified range. The principle of this function is to evenly distribute the values between the starting value and the ending value according to the specified resolution, and the function is to simplify the process of creating a numerical array. Use the np.zeros function to create an array initialized to 0, which is used here to initialize land cover data, where 0 represents ocean and 1 represents land. Use the globe.is_ocean function to determine whether a given latitude and longitude point is an ocean. The principle of this function is to identify oceans and land based on the geographic data of the earth.
[0062] 5) The data format is saved as np.uint8. This format data is an unsigned 8-bit integer. It is suitable for storing integer values in a small range, such as 0 and 1. This can reduce the storage space requirements and improve the efficiency of data processing.
[0063] Considering the data storage volume and processing efficiency, the land cover data is saved in an unsigned 8-bit integer format (np.uint8). This format of data is called "unsigned 8-bit integer" in Chinese, which can effectively represent Boolean values with a smaller storage space.
[0064] The present invention can generate NetCDF format files containing data information of oceans, land, wetlands, lakes, etc. and different resolutions according to needs.
[0065] 3. File reading method
[0066] 6) Read the NetCDF data file, convert the data into BOOL type data and store it in the container.
[0067] 7) Enter the longitude and latitude information to be queried and find the location of the point in the BOOL container. The search method is shown in formula (1):
[0068] i=round((lon-minLon) / stepLon)+round((lat-minLat) / stepLat)×(360 / stepLon)(1); wherein i represents the position index of the calculated coordinate in the array, lon represents the latitude of the input coordinate, ranging from [-180,180], lat represents the longitude of the input coordinate, ranging from [-90,90], stepLon represents the resolution of latitude, stepLat represents the resolution of longitude, and the round() function is a rounding function.
[0069] 8) Pass i to the container and return the result in the container.
[0070] 9) Determine whether the information of all points has been queried.
[0071] 10) The query is completed and the query results of all coordinate points are returned.
[0072] Advantages of the present invention: The present invention can effectively reduce the running time of data reading and judgment, and can significantly improve the program running efficiency when performing large-scale data calculation operations. The present invention uses the NetCDF data format to store land and ocean data, and can generate files containing different information and precision as needed, and the data generation and storage methods are flexible.
[0073] Example 1
[0074] Computational efficiency and accuracy verification
[0075] Shape files, remote sensing recognition, geographic information system (GIS) software, online interface recognition or some development languages have built-in function libraries, but in actual consideration of computational efficiency, C / C++ language is usually used for development. Remote sensing recognition, related software or built-in functions of the language are not suitable for comparison, and the online interface method has no advantage in large-scale data calls considering network transmission. The current mainstream judgment method is to judge through shape format files, and the present invention is judged and compared with this method.
[0076] N coordinate points are generated by random numbers, and the running time of the two methods is counted. The statistical results are as follows Figure 3 As shown in the figure. The statistical results show that when the number of coordinate points is less than 1000, the running time of both methods is within 1000 milliseconds, that is, 1 second. However, when the amount of data is large, the calculation time of the NetCDF method is much shorter than that of the shape method. This is particularly evident in the current methods that require a lot of calculations, such as intelligent algorithms and deep learning algorithms. The difference in the calculation results of the two methods is shown in the figure. Figure 4 As described above, when the amount of calculation is large enough, the calculation error between the two is less than 7%, which can meet the calculation requirements.
[0077] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for identifying land and ocean based on meteorological NetCDF format data, characterized by: The following steps are involved: S1. Generate land data file in NetCDF format; S2, reading the file in step S1; In step S1, a land data file in NetCDF format is generated, including: S11. Establish a longitude and latitude network; S12. Use the global_land_mask library to determine which points are land and perform data type conversion; S13, create NetCDF file and dimension and create variables and assign values; S14, generating an array of equally spaced values within a specified range; S15, save data; In step S12, the global_land_mask library is used to determine which points are land and perform data type conversion, including: Use the globe.is_ocean function of the global_land_mask library to determine which points are land, and set the corresponding landcover array elements to 1; Then data type conversion: convert the data type of the landcover array to np.uint8, which is used to store Boolean values 0 or 1; In step S2, the file reading method includes: S21, read the NetCDF data file, convert the data into BOOL type data and store it in a BOOL container; S22, input the longitude and latitude information to be queried, and find the position of the point in the BOOL container; S23, pass the position i to the BOOL container, and return the result in the BOOL container; S24, determining whether the information of all points has been queried; S25. The query ends and the query results of all coordinate points are returned.
2. The method for identifying land and ocean based on meteorological NetCDF format data according to claim 1, characterized in that: In step S1, the land data file in NetCDF format includes a file organization and a data model. The file organization includes groups and subgroups, and the data model includes dimensions, variables, and attributes.
3. The method for identifying land and ocean based on meteorological NetCDF format data according to claim 1, characterized in that: In step S11, a latitude and longitude network is established, including: Set the latitude and longitude range and resolution, calculate the number of longitude and latitude points, and use the numpy.linspace function to generate equally spaced points within the specified range; Then create the land cover data array: the landcover array is initialized to 0, indicating the ocean.
4. The method for identifying land and ocean based on meteorological NetCDF format data according to claim 1, characterized in that: In step S13, a NetCDF file and dimension are created and variables are created and assigned values, including: Create NetCDF file and dimensions and create variables and assign values: Create variables for latitude and longitude and fill them with values generated by numpy.linspace; Create a landcover variable and use 'u1' as the data type, which represents an unsigned 1-byte integer and is used to store Boolean values. Finally save the data to a NetCDF file.
5. The method for identifying land and ocean based on meteorological NetCDF format data according to claim 1, characterized in that: In step S14, an array of equally spaced values within a specified range is generated, including: The numpy.linspace function in Python generates an array of equally spaced values within a specified range; Use the np.zeros function to create an array initialized to 0 to initialize the land cover data, where 0 represents the ocean and 1 represents the land; Use the globe.is_ocean function to determine whether a given latitude and longitude point is an ocean.
6. The method for identifying land and ocean based on meteorological NetCDF format data according to claim 1, characterized in that: In step S15, the data format is saved as np.uint8.
7. The method for identifying land and ocean based on meteorological NetCDF format data according to claim 1, characterized in that: In step S22, the search method is as shown in formula (1): i=round((lon-minLon) / stepLon)+round((lat-minLat) / stepLat)×(360 / stepLon)(1); Among them, i represents the index of the calculated coordinate position in the array, lon represents the latitude of the input coordinate, the range is [-180,180], lat represents the longitude of the input coordinate, the range is [-90,90], stepLon represents the resolution of latitude, stepLat represents the resolution of longitude, and the round() function is the integer function.
Citation Information
Patent Citations
Rapid sea-land judging method based on high-precision DEM data
CN108052629A
Marine data visualization platform based on MATLAB program
CN112256364A