GIS development, perhaps the most basic, is to understand the coordinate system.
The so-called GIS development is nothing more than processing a pile of spatial data, that is, storage spatial information data. Spatial information is longitude, latitude, elevation and so on. However, the place is that place, and then measurement methods, standards are varied, forming different so-called coordinate system.
I. Classification of geographic coordinate system
The classification and elaboration of the geographical coordinate system is very complicated in Baidu Encyclopedia. After reading it, it will only make people head hum and silly for a long time. According to my current superficial understanding, I simply reduce it to two kinds: geodetic coordinate system and projection coordinate system. In short:
Geodetic coordinate system: spherical coordinate system in units of latitude and longitude. For example, when we talk about a certain location, what’s the latitude and longitude, it’s this spherical coordinate. GPS uses a geodetic coordinate system.
Projection coordinate system:
Plane coordinate systemOften measured in meters. A sphere is a surface, but our map is drawn on a plane, so there is a conversion process. That’s the projection method. The Mercator projection, for example, involves covering the Earth with a cylindrical piece of cardboard. Then a candle at the center of the globe shines, heats up, and projects the earth onto the cardboard, resulting in a plan of the earth.
Geodetic coordinate system and projection coordinate system are major categories, and can be divided into various factions below. For example, the projection coordinate system, there are Mercator projection, Gaussian projection (Gauss-Kruger projection), UTM projection.
Second, the WKID
With all these coordinate systems, how do you identify them? Give it an ID. In ArcGIS, each coordinate system has a unique identifier, WKID. WKID is a Well Known ID. Why is it known? Because this ID is not unique to ArcGIS, it has international standards, but different organizations call it differently, but the value is the same.
1. OGC SRID (Spatial Reference ID)
OGC(Open Geospatial Consortium) is an Open Geospatial Information Consortium. Self-described as a non-profit international standards organization, it sets a set of standards for data and services that GIS vendors develop to ensure interoperability of spatial data.
The OGC has developed a number of standards:
Catalogue Service CS will be used to discover and browse data on server, metadata of Service CityGML will be used to exchange cities3D Model KML KML provides XML-encoded geographic data set (introduced from Google) Coordinate Transformation Service CT to provide the Coordinate system and its Transformation Service Geography Markup Language GML provides xmL-encoded geographic data set Grid Coverage Service Location Services LS Simple Features SFS Common description Web Coverage Processing Service WCPS Web Coverage Service WCS Web Feature Service WFS Web services (vector Map Service WMS Web Service Web Map Tile Service WMTS Web Service Web Processing Service WPS Geographic Processing Service Web Service Common OWS Describes the general specification for OGC Web servicesCopy the code
Among them, WKT(Well known text) is a text markup language used to express vector geometry objects, spatial reference systems and transformations among them. Its binary representation is called WKB(well-known binary).
In addition to representing geometric objects, it can also represent spatial reference systems. A WKT string representing a spatial reference system describes geodesic datum, geoid, coordinate system and map projection of a space object. WKT is widely used in many GIS programs. ESRI also uses WKT in its Shape file format (*.prj). Here is a sample REPRESENTATION of WKT for a space-referenced system:
COMPD_CS["OSGB36 / British National Grid + ODN",
PROJCS["OSGB 1936 / British National Grid",
GEOGCS["OSGB 1936",
DATUM["OSGB_1936",
spheroid["Airy 1830".6377563.396.299.3249646,AUTHORITY["EPSG"."7001"]],
TOWGS84[375.- 111..431.0.0.0.0],
AUTHORITY["EPSG"."6277"]],
PRIMEM["Greenwich".0,AUTHORITY["EPSG"."8901"]],
UNIT["DMSH".0.0174532925199433,AUTHORITY["EPSG"."9108"]],
AXIS["Lat",NORTH],
AXIS["Long",EAST],
AUTHORITY["EPSG"."4277"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin".49],
PARAMETER["central_meridian".2 -],
PARAMETER["scale_factor".0.999601272],
PARAMETER["false_easting".400000],
PARAMETER["false_northing".- 100000.],
UNIT["metre".1,AUTHORITY["EPSG"."9001"]],
AXIS["E",EAST],
AXIS["N",NORTH],
AUTHORITY["EPSG"."27700"]],
VERT_CS["Newlyn",
VERT_DATUM["Ordnance Datum Newlyn".2005,AUTHORITY["EPSG"."5101"]],
UNIT["metre".1,AUTHORITY["EPSG"."9001"]],
AXIS["Up",UP],
AUTHORITY["EPSG"."5701"]],
AUTHORITY["EPSG"."7405"]]
Copy the code
OGC is used to identify different Spatial Reference systems, using SRID,Spatial Reference ID?
The Full English name of EPSG is European Petroleum Survey Group. The Chinese name is European Petroleum Survey Group. The organization was founded in 1986 and merged into the International Association of Oil & Gas Producers (IOGP) in 2005. EPSG has maps of every part of the world, probably to find oil easily.
EPSG’s original goal was to improve and share location data around the world, responsible for publishing and maintaining data set parameters for coordinate reference systems, as well as coordinate transformation descriptions, which are widely accepted and used. The most famous one is EPSG:4326, which is used by the US-led GPS System. It is also known as WGS84. WGS(World Geodetic System) stands for World Geodetic System, which was defined in 1984. Previous versions include WGS72, WGS66, and WGS60.
EPSG identifies the different coordinate systems with EPSG CODE.
3. ArcGIS WKID In ArcGIS, WKID is used as the identification of coordinate reference system.
Find WKID in ArcGIS
SRID, EPSG CODE, and WKID are the ids used by different organizations and entities to identify different coordinate systems, but fortunately, their values are consistent.
The organization is much, may not inevitably bump against, coordination.
For example, the Web Mercator coordinate system uses a projection method that is not strictly Mercator projection, but a projection method that EPSG calls pseudo-Mercator. The name of this pseudo-mercator projection method is Popular Mercator, PVPM. It seems that this projection method is not very rigorous, popular, right? Popular? Visualized pseudo-Mercator projection… Because this coordinate system was first used by Google Maps, or rather, invented by Google. In the projection process, the reference ellipsoid representing the earth is approximated as a normal sphere (the radius of the normal sphere R = the semi-major axis of the ellipsoid A). This is why in ArcGIS we often see this coordinate system called WGS 1984 Web Mercator (Auxiliary Sphere). Auxiliary Sphere tells you that the coordinates approximate the ellipsoid as a normal Sphere during the projection process, even though the datum is the WGS 1984 ellipsoid. Later, Web Mercator became widely used in Web mapping, and the coordinate system became famous. Although this coordinate system was not accepted by GIS professionals due to its accuracy, EPSG eventually gave it a number, WKID:3857.
Before this, ArcGIS had assigned it an ID: 102100 (102113 at the beginning), so now in ArcGIS, both IDS can be used, and both refer to the same coordinate system. Arcgis itself identifies it as follows:
"spatialReference": {"wkid":102100."latestWkid":3857}
Copy the code
Coordinate system transformation
Spatial data in different coordinate systems cannot be mixed together. For example, with ArcGIS for JS overlay layer, if the coordinate system of two layers is not consistent, it is likely to be impossible to stack. Unless ArcGIS defaults to automatic processing, such as wKID =4326 and wKID =102100(3875).
Therefore, before using it, data in different coordinate systems should be transformed into the same one.
How do I convert? Take Java as an example:
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.opengis.geometry.MismatchedDimensionException;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
public static Geometry trans2WGS1984(int wkid, Geometry geom)
throws FactoryException, MismatchedDimensionException, TransformException {
CoordinateReferenceSystem targetCRS = CRS.decode(String.format("EPSG:%d".3857));
/* * * /* * Some projections, like the Gaussian projection, XY is the opposite of the normal coordinate system, the X-axis is what we normally call the Y-axis, and the Y-axis is the X-axis, just reversed. To deal with that, you use this function. Otherwise, the conversion is not successful, report what: The transform result may be 482.279 meters away from The expected position. Are you sure that The input coordinates Are inside this map projection area of validity? The point is located 32° 36.2'e away from The Central Meridian and 0° 19.8'n away from The latitude of origin. The projection is "Transverse_Mercator". */
CRSAuthorityFactory factory = CRS.getAuthorityFactory(true);
CoordinateReferenceSystem sourceCRS = factory.createCoordinateReferenceSystem(String.format("EPSG:%d",wkid));
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS,true);// The last argument to true is necessary to indicate that the mode is tolerant and the elevation can be ignored
return JTS.transform(geom,transform);
}
Copy the code
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>23.0</version>
</dependency>
Copy the code
You can also construct this frame object this way
String wktCgcs2000 = "PROJCS[\"CGCS2000 / Gauss-Kruger CM 123E\",GEOGCS[\"China Geodetic Coordinate System 2000 \ ", DATUM [\ "China_2000 \", SPHEROID [\ "CGCS2000 \", the 6378137298257221-01, AUTHORITY [\ "EPSG \", \ "1024 \"]], AUTHORITY [\ "EPSG \" PRIMEM, \ "1043 \"]], [\ "Greenwich \", 0, AUTHORITY [\ "EPSG \", \ "8901 \"]], the UNIT [\ "degree \", 0.0174532925199433, AUTHORITY [\ \ "EPSG \" "9122\"]],AUTHORITY[\"EPSG\",\"4490\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Transverse_Mercator\ "],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",123],PARAMETER[\"scale_factor\",1],PARAMETER[\"fal se_easting\",500000],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"4507\"],AXIS[\"X\",NORTH],AXIS[\"Y\",EAST]]";
CoordinateReferenceSystem crsCGCS2000 = CRS.parseWKT(wktCgcs2000);
Copy the code
Arcgis for JSAPI development: Coordinate system, latitude and longitude and plane coordinates interchange Ogc standard WKT Introduction EPSG is what? WGS_1984_Web_Mercator_Auxiliary_Sphere