Error
Error Code:
3740
MySQL Error 3740: Invalid Prime Meridian Coordinate
Description
Error 3740 occurs when attempting to define or modify a Spatial Reference System (SRS) where the specified prime meridian value falls outside the valid range of (-180, 180] degrees. This error indicates that the geographic coordinate system's prime meridian parameter is syntactically incorrect according to spatial standards.
Error Message
The prime meridian must be within (-180, 180] degrees, specified in the SRS angular unit.
Known Causes
3 known causesManual Input Error
A prime meridian value was manually provided outside the valid range of (-180, 180] degrees during SRS definition or modification.
Data Import/Migration Issue
Imported or migrated spatial data or SRS definitions contain an invalid prime meridian value that violates the specified range.
Application Code Error
An application or script attempted to define an SRS with a prime meridian value outside the allowed (-180, 180] degree range.
Solutions
3 solutions available1. Correct Invalid Prime Meridian Value in Spatial Data medium
Identify and correct the invalid prime meridian coordinate in your spatial data.
1
Identify the table and column containing the spatial data that is causing the error. You'll likely need to examine tables with spatial data types like POINT, POLYGON, etc.
SHOW TABLES LIKE '%spatial%';
-- Or query your schema to find spatial columns.
2
Query the spatial data to find the specific record(s) with an invalid prime meridian. This often involves looking at the SRID (Spatial Reference System Identifier) and potentially the coordinate values themselves. For SRIDs associated with geographic coordinate systems, the prime meridian is implicitly defined. If you're manually constructing WKT (Well-Known Text) or WKB (Well-Known Binary), ensure the coordinates are valid.
SELECT ST_AsText(your_spatial_column) FROM your_table WHERE ... -- Add conditions to filter problematic rows if known.
-- If you suspect an issue with a specific SRID, check its definition.
SELECT * FROM spatial_ref_sys WHERE srid = your_srid_value;
3
Update the spatial data with a valid prime meridian. If you are using a standard SRID, this usually means ensuring your input coordinates are relative to Greenwich. If you are manually constructing spatial data, ensure your longitude values are within the range of (-180, 180].
UPDATE your_table SET your_spatial_column = ST_GeomFromText('POINT(longitude latitude)', your_srid) WHERE id = specific_row_id;
-- Example: Correcting a longitude value that is too large or small.
-- If your SRS uses a different prime meridian, you might need to transform coordinates or consult the SRS definition.
2. Verify and Correct SRID Configuration advanced
Ensure the Spatial Reference System (SRS) used by your data is correctly configured and defined in MySQL.
1
Identify the SRID associated with your spatial data. This is often stored with the spatial column or can be inferred from the spatial functions being used.
SELECT DISTINCT ST_SRID(your_spatial_column) FROM your_table;
2
Query the `spatial_ref_sys` table to inspect the definition of the SRID. Pay close attention to the `proj_parameters` and `srid_name` fields for any indications of an incorrect prime meridian definition.
SELECT * FROM spatial_ref_sys WHERE srid = your_srid_value;
3
If the SRID definition in `spatial_ref_sys` is incorrect or missing crucial information about the prime meridian, you may need to update it. **Caution:** Modifying `spatial_ref_sys` can have widespread impacts on your spatial data. It's highly recommended to back up this table before making changes.
UPDATE spatial_ref_sys SET proj_parameters = '...' WHERE srid = your_srid_value;
-- Consult official GIS documentation for correct `proj_parameters` for your desired SRS.
-- Alternatively, if the SRID is not standard, you might need to insert a new entry or use a different, well-defined SRID.
4
If you are using a custom SRID, ensure that its definition accurately reflects the prime meridian. For standard geographic coordinate systems (like WGS84), the prime meridian is Greenwich, and longitude values should be within (-180, 180].
INSERT INTO spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text, proj_parameters) VALUES (your_new_srid, 'EPSG', your_auth_srid, 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]];', '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]];');
3. Re-import Spatial Data with Corrected Coordinates medium
Export problematic spatial data, correct coordinates, and re-import.
1
Export the spatial data that is causing the error. Use `ST_AsText` or `ST_AsGeoJSON` to get human-readable representations of your geometries.
SELECT id, ST_AsText(your_spatial_column) AS wkt_data FROM your_table WHERE ... -- Filter for problematic rows.
2
Manually review the exported data. Identify any longitude values that are outside the valid range of (-180, 180]. If your coordinate system uses a different prime meridian, understand how your input coordinates relate to it.
text editor or scripting language (Python, etc.) to review the WKT strings.
3
Correct the invalid longitude values. For example, if you have a longitude of 200 degrees, and your system expects values between -180 and 180, you might need to convert it to -160 degrees (200 - 360).
Modify the WKT strings or the source data before re-importing.
4
Prepare the corrected data for import. This might involve creating an `INSERT` statement with `ST_GeomFromText` or using a data loading tool that supports spatial data.
UPDATE your_table SET your_spatial_column = ST_GeomFromText('POINT(corrected_longitude latitude)', your_srid) WHERE id = specific_row_id;
5
Execute the `UPDATE` or `INSERT` statements to re-import the corrected spatial data.
Run the SQL statements generated in the previous step.