Coordinate systems and Shapefile
Convert coordinates from one reference system to another by EPSG code (one point, JSON rows or a whole GeoJSON), describe a system with its area of use and accuracy, and read or write ESRI Shapefiles with their projection file. The official systems of mainland France (Lambert-93, the CC zones, the old Lambert II etendu) and of the overseas territories (La Reunion, Mayotte, the Antilles, Guyane, Saint-Pierre-et-Miquelon, Polynesia, New Caledonia) are built in, with every UTM zone. Typical uses: give GPS points to a GIS team in the local projection, show a Shapefile on a web map, bring an old Lambert II file into Lambert-93.
geo transformgeo transformgeo transform_rowsgeo transform_rowsgeo transform_geojsongeo transform_geojsongeo crsgeo crsshp writeshp writeshp infoshp readshp read
geo transform <x_or_lat> <y_or_lon> <from_crs> <to_crs>
Description
Transform one point from a CRS to another. For a geographic source CRS the first value is the latitude. Returns {from, to, x, y, inside_area} for a projected target or {from, to, latitude, longitude, inside_area} for a geographic one. inside_area is true when the point is inside the areas of use of both CRS, false when it is outside one of them, null when an area is not known and the point is not outside the other one
Transform one point from a CRS to another. For a geographic source CRS the first value is the latitude. Returns {from, to, x, y, inside_area} for a projected target or {from, to, latitude, longitude, inside_area} for a geographic one. inside_area is true when the point is inside the areas of use of both CRS, false when it is outside one of them, null when an area is not known and the point is not outside the other one
Parameters
x_or_lat: x (easting) or the latitude for a geographic CRS - Number - required
y_or_lon: y (northing) or the longitude - Number - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
x_or_lat: x (easting) or the latitude for a geographic CRS - Number - required
y_or_lon: y (northing) or the longitude - Number - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
admin
geo transform "-20.8789" "55.4481" "4326" "2975"
mentdb
{"from": "EPSG:4326", "to": "EPSG:2975", "x": 338568.315, "y": 7690475.4366, "inside_area": true}
And back
admin
geo transform "338568.315" "7690475.4366" "EPSG:2975" "EPSG:4326"
mentdb
{"from": "EPSG:2975", "to": "EPSG:4326", "latitude": -20.8789, "longitude": 55.4481, "inside_area": true}
Notre-Dame de Paris in Lambert-93
admin
geo transform "48.853" "2.3499" "wgs84" "lambert93"
mentdb
{"from": "EPSG:4326", "to": "EPSG:2154", "x": 652296.9731, "y": 6861636.3585, "inside_area": true}
Lambert-93 to the conic zone CC49 (Paris)
admin
geo transform "652208" "6861420" "2154" "3949"
mentdb
{"from": "EPSG:2154", "to": "EPSG:3949", "x": 1652206.636, "y": 8183641.6791, "inside_area": true}
An old map in Lambert II etendu to Lambert-93
admin
geo transform "600000" "2430000" "27572" "2154"
mentdb
{"from": "EPSG:27572", "to": "EPSG:2154", "x": 651328.4428, "y": 6863348.1454, "inside_area": true}
Fort-de-France, Martinique (RGAF09 / UTM 20N)
admin
geo transform "14.6037" "-61.0731" "4326" "5490"
mentdb
{"from": "EPSG:4326", "to": "EPSG:5490", "x": 707567.1235, "y": 1615374.473, "inside_area": true}
Cayenne, Guyane (RGFG95 / UTM 22N)
admin
geo transform "4.9372" "-52.326" "4326" "2972"
mentdb
{"from": "EPSG:4326", "to": "EPSG:2972", "x": 352980.2046, "y": 545868.9224, "inside_area": true}
Mamoudzou, Mayotte (RGM04 / UTM 38S)
admin
geo transform "-12.7806" "45.2279" "4326" "4471"
mentdb
{"from": "EPSG:4326", "to": "EPSG:4471", "x": 524735.3747, "y": 8587115.8115, "inside_area": true}
Saint-Pierre (RGSPM06 / UTM 21N)
admin
geo transform "46.7811" "-56.1764" "4326" "4467"
mentdb
{"from": "EPSG:4326", "to": "EPSG:4467", "x": 562869.8033, "y": 5181168.3164, "inside_area": true}
The latitude and longitude swapped: inside_area false
admin
geo transform "55.4481" "-20.8789" "4326" "2975"
mentdb
{"from": "EPSG:4326", "to": "EPSG:2975", "x": -3492247.1116, "y": 1.90807710353E7, "inside_area": false}
A latitude over 90
admin
geo transform "152.3" "48.8" "4326" "2154"
mentdb
ERROR: Sorry, an error appears (the latitude must be from -90 to 90 (x_or_lat is the latitude, or set lon_first true)).
geo transform <x_or_lat> <y_or_lon> <from_crs> <to_crs> <json_params>
Description
Transform with parameters: lon_first (false: true when the longitude comes first, for the input and the output of a geographic CRS), decimals (4 for meters, 9 for degrees, from 0 to 15)
Transform with parameters: lon_first (false: true when the longitude comes first, for the input and the output of a geographic CRS), decimals (4 for meters, 9 for degrees, from 0 to 15)
Parameters
x_or_lat: x, or the latitude (the longitude with lon_first) - Number - required
y_or_lon: y, or the longitude (the latitude with lon_first) - Number - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
json_params: The parameters - String - required
x_or_lat: x, or the latitude (the longitude with lon_first) - Number - required
y_or_lon: y, or the longitude (the latitude with lon_first) - Number - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
json_params: The parameters - String - required
admin
geo transform "55.4481" "-20.8789" "wgs84" "utm40s" "{\"lon_first\": true}"
mentdb
{"from": "EPSG:4326", "to": "EPSG:32740", "x": 338568.315, "y": 7690475.4365, "inside_area": true}
Web Mercator (web maps) to WGS84 with 6 decimals, longitude first
admin
geo transform "6172462" "-2377512" "3857" "4326" "{\"lon_first\": true, \"decimals\": 6}"
mentdb
{"from": "EPSG:3857", "to": "EPSG:4326", "longitude": 55.44817, "latitude": -20.879466, "inside_area": true}
geo transform_rows <json_rows> <from_crs> <to_crs>
Description
Transform the coordinates of JSON rows (2 million at most). By default the source fields are lon and lat for a geographic CRS, else x and y, and the new values go into lon and lat for a geographic target, else x and y (they replace fields with the same names). A row with an empty coordinate gets null. Returns the rows
Transform the coordinates of JSON rows (2 million at most). By default the source fields are lon and lat for a geographic CRS, else x and y, and the new values go into lon and lat for a geographic target, else x and y (they replace fields with the same names). A row with an empty coordinate gets null. Returns the rows
Parameters
json_rows: The rows - String - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
json_rows: The rows - String - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
admin
geo transform_rows "[{\"site\": \"Saint-Denis\", \"lat\": -20.8789, \"lon\": 55.4481}, {\"site\": \"Saint-Pierre\", \"lat\": -21.3393, \"lon\": 55.4781}, {\"site\": \"unknown\", \"lat\": null, \"lon\": null}]" "4326" "2975"
mentdb
[{"site": "Saint-Denis", "lat": -20.8789, "lon": 55.4481, "x": 338568.315, "y": 7690475.4366}, {"site": "Saint-Pierre", "lat": -21.3393, "lon": 55.4781, "x": 342177.2155, "y": 7639537.4907}, {"site": "unknown", "lat": null, "lon": null, "x": null, "y": null}]
geo transform_rows <json_rows> <from_crs> <to_crs> <json_params>
Description
Transform rows with parameters: x_field and y_field (the source fields), out_x_field and out_y_field (the target fields), decimals, strict (true: a value that is not a number or a point outside the projection is an error naming the row; false gives null)
Transform rows with parameters: x_field and y_field (the source fields), out_x_field and out_y_field (the target fields), decimals, strict (true: a value that is not a number or a point outside the projection is an error naming the row; false gives null)
Parameters
json_rows: The rows - String - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
json_params: The parameters - String - required
json_rows: The rows - String - required
from_crs: The CRS of the coordinates: an EPSG code (4326, EPSG:2154, urn:ogc:def:crs:EPSG::2975) or wgs84, lambert93, webmercator, lambert2e, utm40s - String - required
to_crs: The CRS wanted (same forms) - String - required
json_params: The parameters - String - required
admin
geo transform_rows "[{\"id\": 1, \"x\": 652469.02, \"y\": 6862035.26}, {\"id\": 2, \"x\": 843000, \"y\": 6519000}]" "2154" "4326" "{\"out_x_field\": \"longitude\", \"out_y_field\": \"latitude\", \"decimals\": 6}"
mentdb
[{"id": 1, "x": 652469.02, "y": 6862035.26, "longitude": 2.3522, "latitude": 48.8566}, {"id": 2, "x": 843000, "y": 6519000, "longitude": 4.839711, "latitude": 45.755609}]
strict false: a bad value gives null
admin
geo transform_rows "[{\"id\": 1, \"lat\": \"-20.88\", \"lon\": \"55.45\"}, {\"id\": 2, \"lat\": \"n/a\", \"lon\": \"55.45\"}]" "4326" "2975" "{\"strict\": false}"
mentdb
[{"id": 1, "lat": "-20.88", "lon": "55.45", "x": 338767.1674, "y": 7690355.5724}, {"id": 2, "lat": "n/a", "lon": "55.45", "x": null, "y": null}]
Used in use cases (1 recipe)
Integrator & ETL developer › Give GPS points to a GIS team as a Shapefile in the local projection
Integrator & ETL developer › Give GPS points to a GIS team as a Shapefile in the local projection
geo transform_geojson <geojson> <from_crs> <to_crs>
Description
Transform every position of a GeoJSON (FeatureCollection, Feature or geometry, 10 million positions at most), longitude first as in RFC 7946. An empty from_crs takes the legacy crs member of the GeoJSON, else WGS84. The heights are kept, a bbox member is computed again. For a target other than 4326 the legacy crs member (urn:ogc:def:crs:EPSG::code) is written, as GDAL does
Transform every position of a GeoJSON (FeatureCollection, Feature or geometry, 10 million positions at most), longitude first as in RFC 7946. An empty from_crs takes the legacy crs member of the GeoJSON, else WGS84. The heights are kept, a bbox member is computed again. For a target other than 4326 the legacy crs member (urn:ogc:def:crs:EPSG::code) is written, as GDAL does
Parameters
geojson: The GeoJSON - String - required
from_crs: The CRS of the coordinates, empty for the crs member or WGS84 - String - required
to_crs: The CRS wanted (same forms) - String - required
geojson: The GeoJSON - String - required
from_crs: The CRS of the coordinates, empty for the crs member or WGS84 - String - required
to_crs: The CRS wanted (same forms) - String - required
admin
geo transform_geojson "{\"type\": \"FeatureCollection\", \"features\": [{\"type\": \"Feature\", \"properties\": {\"name\": \"Piton des Neiges\"}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [55.48, -21.099, 3070]}}, {\"type\": \"Feature\", \"properties\": {\"name\": \"path\"}, \"geometry\": {\"type\": \"LineString\", \"coordinates\": [[55.45, -21.05], [55.47, -21.08]]}}]}" "" "2975"
mentdb
{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::2975"}}, "features": [{"type": "Feature", "properties": {"name": "Piton des Neiges"}, "geometry": {"type": "Point", "coordinates": [342118.7911, 7666141.697, 3070]}}, {"type": "Feature", "properties": {"name": "path"}, "geometry": {"type": "LineString", "coordinates": [[338949.3726, 7671536.1257], [341059.7001, 7668235.1045]]}}]}
Back to WGS84 with the crs member
admin
geo transform_geojson "{\"type\": \"Feature\", \"crs\": {\"type\": \"name\", \"properties\": {\"name\": \"urn:ogc:def:crs:EPSG::2975\"}}, \"properties\": {}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [343584.4123, 7666334.6531]}}" "" "4326"
mentdb
{"type": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [55.494124126, -21.097383008]}}
geo transform_geojson <geojson> <from_crs> <to_crs> <json_params>
Description
Transform a GeoJSON with parameters: decimals (4 for meters, 9 for degrees), crs_member (true: false never writes the legacy crs member)
Transform a GeoJSON with parameters: decimals (4 for meters, 9 for degrees), crs_member (true: false never writes the legacy crs member)
Parameters
geojson: The GeoJSON - String - required
from_crs: The CRS of the coordinates, empty for the crs member or WGS84 - String - required
to_crs: The CRS wanted (same forms) - String - required
json_params: The parameters - String - required
geojson: The GeoJSON - String - required
from_crs: The CRS of the coordinates, empty for the crs member or WGS84 - String - required
to_crs: The CRS wanted (same forms) - String - required
json_params: The parameters - String - required
admin
geo transform_geojson "{\"type\": \"Polygon\", \"coordinates\": [[[55.2, -21.4], [55.8, -21.4], [55.8, -20.9], [55.2, -20.9], [55.2, -21.4]]]}" "4326" "3857" "{\"decimals\": 2, \"crs_member\": false}"
mentdb
{"type": "Polygon", "coordinates": [[[6144835.89, -2439638.73], [6211627.59, -2439638.73], [6211627.59, -2379958.64], [6144835.89, -2379958.64], [6144835.89, -2439638.73]]]}
geo crs <crs>
Description
Describe a CRS: code, epsg, name, kind (projected or geographic), unit, axis, area (of use), bbox_wgs84 [west, south, east, north], datum_shift (how it is linked to WGS84 and how good it is), accuracy_m, checked_against_proj (true for the CRS compared with PROJ in the tests), proj4 (the definition used)
Describe a CRS: code, epsg, name, kind (projected or geographic), unit, axis, area (of use), bbox_wgs84 [west, south, east, north], datum_shift (how it is linked to WGS84 and how good it is), accuracy_m, checked_against_proj (true for the CRS compared with PROJ in the tests), proj4 (the definition used)
Parameters
crs: An EPSG code or a short name - String - required
crs: An EPSG code or a short name - String - required
admin
geo crs "2975"
mentdb
{"code": 2975, "epsg": "EPSG:2975", "name": "RGR92 / UTM zone 40S", "kind": "projected", "unit": "metre", "axis": "x easting, y northing", "area": "La Reunion", "bbox_wgs84": [54, -24.72, 58.24, -18.28], "datum_shift": "the national frame is taken as equal to WGS84 (null transformation, as PROJ does without a grid): about 1 m", "accuracy_m": 1, "checked_against_proj": true, "proj4": "+proj=utm +zone=40 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"}
Lambert II etendu: the datum shift is the weak point
admin
geo crs "27572"
mentdb
{"code": 27572, "epsg": "EPSG:27572", "name": "NTF (Paris) / Lambert zone II", "kind": "projected", "unit": "metre", "axis": "x easting, y northing", "area": "France mainland (Lambert II etendu, former NTF)", "bbox_wgs84": [-4.87, 42.33, 8.23, 51.14], "datum_shift": "NTF to WGS84 by the 3-parameter Helmert transformation -168, -60, 320 (EPSG:1193, given for 2 m by IGN); compared with the IGN grid of PROJ: 1.7 m median, 4.6 m for 95% of the points, 8.5 m at most. The grid itself is not used", "accuracy_m": 2, "checked_against_proj": true, "proj4": "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs"}
A code that is not supported
admin
geo crs "4978"
mentdb
ERROR: Sorry, an error appears (the parameter 'crs': EPSG:4978 is a geocentric CRS (x, y, z): not supported).
geo crs <crs> <json_params>
Description
Describe a CRS with parameters: prj (false: true adds the text of the .prj file that shp write writes, ESRI WKT for the known CRS)
Describe a CRS with parameters: prj (false: true adds the text of the .prj file that shp write writes, ESRI WKT for the known CRS)
Parameters
crs: An EPSG code or a short name - String - required
json_params: The parameters - String - required
crs: An EPSG code or a short name - String - required
json_params: The parameters - String - required
admin
geo crs "utm40s" "{\"prj\": true}"
mentdb
{"code": 32740, "epsg": "EPSG:32740", "name": "WGS 84 / UTM zone 40S", "kind": "projected", "unit": "metre", "axis": "x easting, y northing", "area": "UTM zone 40S: from 54E to 60E, southern hemisphere", "bbox_wgs84": [54, -80, 60, 0], "datum_shift": "none (WGS84)", "accuracy_m": 0, "checked_against_proj": true, "proj4": "+proj=utm +zone=40 +south +datum=WGS84 +units=m +no_defs", "prj": "PROJCS[\"WGS_1984_UTM_Zone_40S\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",500000.0],PARAMETER[\"False_Northing\",10000000.0],PARAMETER[\"Central_Meridian\",57.0],PARAMETER[\"Scale_Factor\",0.9996],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]"}
Used in use cases (1 recipe)
Mechanical & civil engineer › Bring an old Lambert II etendu Shapefile into Lambert-93
Mechanical & civil engineer › Bring an old Lambert II etendu Shapefile into Lambert-93
shp write <shp_path> <data>
Description
Write a Shapefile from GeoJSON (FeatureCollection, Feature or geometry) or from JSON rows with a WKT field (wkt). The shape type is the one of the first geometry: Point, MultiPoint, PolyLine (LineString and MultiLineString) or Polygon (Polygon and MultiPolygon); with a third coordinate, the Z type. The .prj comes from the legacy crs member of the GeoJSON, else EPSG:4326 for GeoJSON (none for rows). Field types come from the values: integers and decimals N, booleans L, YYYY-MM-DD texts D, other texts C (objects and arrays as JSON text). The folder is created. Returns {path, shape_type, count, null_geometries, fields, renamed, truncated_values, crs, encoding, files, bytes}
Write a Shapefile from GeoJSON (FeatureCollection, Feature or geometry) or from JSON rows with a WKT field (wkt). The shape type is the one of the first geometry: Point, MultiPoint, PolyLine (LineString and MultiLineString) or Polygon (Polygon and MultiPolygon); with a third coordinate, the Z type. The .prj comes from the legacy crs member of the GeoJSON, else EPSG:4326 for GeoJSON (none for rows). Field types come from the values: integers and decimals N, booleans L, YYYY-MM-DD texts D, other texts C (objects and arrays as JSON text). The folder is created. Returns {path, shape_type, count, null_geometries, fields, renamed, truncated_values, crs, encoding, files, bytes}
Parameters
shp_path: The .shp file (the others take the same name) - String - required
data: GeoJSON or rows - String - required
shp_path: The .shp file (the others take the same name) - String - required
data: GeoJSON or rows - String - required
admin
shp write "tmp/doc_geox/parcs.shp" "{\"type\": \"FeatureCollection\", \"crs\": {\"type\": \"name\", \"properties\": {\"name\": \"urn:ogc:def:crs:EPSG::2975\"}}, \"features\": [{\"type\": \"Feature\", \"properties\": {\"name\": \"Parc du Colorado\", \"area_ha\": 14.5, \"opened\": \"1998-06-01\", \"playground\": true}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[338000, 7690000], [338400, 7690000], [338400, 7690400], [338000, 7690400], [338000, 7690000]], [[338100, 7690100], [338100, 7690200], [338200, 7690200], [338200, 7690100], [338100, 7690100]]]}}, {\"type\": \"Feature\", \"properties\": {\"name\": \"Jardin de l'Etat\", \"area_ha\": 9, \"opened\": \"1773-01-01\", \"playground\": false}, \"geometry\": {\"type\": \"Polygon\", \"coordinates\": [[[339000, 7690000], [339300, 7690000], [339300, 7690300], [339000, 7690300], [339000, 7690000]]]}}]}"
mentdb
{"path": "tmp/doc_geox/parcs.shp", "shape_type": "Polygon", "count": 2, "null_geometries": 0, "fields": [{"name": "name", "type": "C", "length": 16, "decimals": 0}, {"name": "area_ha", "type": "N", "length": 4, "decimals": 1}, {"name": "opened", "type": "D", "length": 8, "decimals": 0}, {"name": "playground", "type": "L", "length": 1, "decimals": 0}], "renamed": {}, "truncated_values": 0, "crs": "EPSG:2975", "encoding": "UTF-8", "files": ["parcs.shp", "parcs.shx", "parcs.dbf", "parcs.prj", "parcs.cpg"], "bytes": 1202}
Rows with a WKT line
admin
shp write "tmp/doc_geox/routes.shp" "[{\"road\": \"RN1\", \"lanes\": 4, \"wkt\": \"LINESTRING (338000 7690000, 340000 7691000, 342000 7691500)\"}, {\"road\": \"RN2\", \"lanes\": 2, \"wkt\": \"LINESTRING (338000 7690000, 336000 7688000)\"}]"
mentdb
{"path": "tmp/doc_geox/routes.shp", "shape_type": "PolyLine", "count": 2, "null_geometries": 0, "fields": [{"name": "road", "type": "C", "length": 3, "decimals": 0}, {"name": "lanes", "type": "N", "length": 1, "decimals": 0}], "renamed": {}, "truncated_values": 0, "crs": null, "encoding": "UTF-8", "files": ["routes.shp", "routes.shx", "routes.dbf", "routes.cpg"], "bytes": 521}
shp write <shp_path> <data> <json_params>
Description
Write a Shapefile with parameters: type (point, multipoint, line or polygon, to force it or for data without geometry), crs (the EPSG code of the .prj: the coordinates are not transformed, use geo transform_geojson or geo transform_rows first), encoding (UTF-8 by default, windows-1252 or ISO-8859-1, written in the .cpg), geometry_field (wkt) or x_field and y_field (points from two number fields of the rows), fields (the .dbf fields in this order: [{name (10 letters, digits or _ at most), type C N F L or D, length, decimals, source (the property, the name by default)}])
Write a Shapefile with parameters: type (point, multipoint, line or polygon, to force it or for data without geometry), crs (the EPSG code of the .prj: the coordinates are not transformed, use geo transform_geojson or geo transform_rows first), encoding (UTF-8 by default, windows-1252 or ISO-8859-1, written in the .cpg), geometry_field (wkt) or x_field and y_field (points from two number fields of the rows), fields (the .dbf fields in this order: [{name (10 letters, digits or _ at most), type C N F L or D, length, decimals, source (the property, the name by default)}])
Parameters
shp_path: The .shp file - String - required
data: GeoJSON or rows - String - required
json_params: The parameters - String - required
shp_path: The .shp file - String - required
data: GeoJSON or rows - String - required
json_params: The parameters - String - required
admin
shp write "tmp/doc_geox/ecoles.shp" "[{\"name\": \"Ecole Champ Fleuri\", \"pupils\": 312, \"lat\": -20.892, \"lon\": 55.465, \"opened\": \"1975-09-01\"}, {\"name\": \"Ecole Raphael Babet\", \"pupils\": 254, \"lat\": -21.3405, \"lon\": 55.477, \"opened\": \"1982-09-01\"}, {\"name\": \"Collège Bourbon\", \"pupils\": 980, \"lat\": -20.88, \"lon\": 55.454, \"opened\": \"1961-09-01\"}]" "{\"x_field\": \"lon\", \"y_field\": \"lat\", \"crs\": \"4326\", \"encoding\": \"windows-1252\", \"fields\": [{\"name\": \"NOM\", \"source\": \"name\", \"type\": \"C\", \"length\": 40}, {\"name\": \"ELEVES\", \"source\": \"pupils\", \"type\": \"N\", \"length\": 6}, {\"name\": \"OUVERTURE\", \"source\": \"opened\", \"type\": \"D\"}]}"
mentdb
{"path": "tmp/doc_geox/ecoles.shp", "shape_type": "Point", "count": 3, "null_geometries": 0, "fields": [{"name": "NOM", "type": "C", "length": 40, "decimals": 0}, {"name": "ELEVES", "type": "N", "length": 6, "decimals": 0}, {"name": "OUVERTURE", "type": "D", "length": 8, "decimals": 0}], "renamed": {"name": "NOM", "pupils": "ELEVES", "opened": "OUVERTURE"}, "truncated_values": 0, "crs": "EPSG:4326", "encoding": "windows-1252", "files": ["ecoles.shp", "ecoles.shx", "ecoles.dbf", "ecoles.prj", "ecoles.cpg"], "bytes": 752}
A WKT field with another name and the CRS of the .prj
admin
shp write "tmp/doc_geox/routes2.shp" "[{\"road\": \"RD41\", \"geom\": \"LINESTRING (338000 7690000, 338500 7689000)\"}]" "{\"geometry_field\": \"geom\", \"crs\": \"2975\"}"
mentdb
{"path": "tmp/doc_geox/routes2.shp", "shape_type": "PolyLine", "count": 1, "null_geometries": 0, "fields": [{"name": "road", "type": "C", "length": 4, "decimals": 0}], "renamed": {}, "truncated_values": 0, "crs": "EPSG:2975", "encoding": "UTF-8", "files": ["routes2.shp", "routes2.shx", "routes2.dbf", "routes2.prj", "routes2.cpg"], "bytes": 775}
shp info <shp_path>
Description
Look inside a Shapefile without reading the geometries: geometry_type, shape_type, z, m, count, records_from, dbf_records, deleted_records, bbox (from the header), z_range, crs {epsg, name, source}, prj_name, bbox_wgs84, encoding, encoding_source, fields [{name, type, length, decimals}], files (which companion files exist) and warnings (counts that differ, no .prj, an unknown CRS...)
Look inside a Shapefile without reading the geometries: geometry_type, shape_type, z, m, count, records_from, dbf_records, deleted_records, bbox (from the header), z_range, crs {epsg, name, source}, prj_name, bbox_wgs84, encoding, encoding_source, fields [{name, type, length, decimals}], files (which companion files exist) and warnings (counts that differ, no .prj, an unknown CRS...)
Parameters
shp_path: The .shp file - String - required
shp_path: The .shp file - String - required
admin
shp info "tmp/doc_geox/parcs.shp"
mentdb
{"path": "tmp/doc_geox/parcs.shp", "geometry_type": "Polygon", "shape_type": "Polygon", "z": false, "m": false, "count": 2, "records_from": "shx index", "dbf_records": 2, "deleted_records": 0, "bbox": [338000, 7690000, 339300, 7690400], "z_range": null, "crs": {"epsg": "EPSG:2975", "name": "RGR92 / UTM zone 40S", "source": "prj name"}, "prj_name": "RGR_1992_UTM_40S", "bbox_wgs84": [55.442594, -20.883258, 55.455125, -20.879532], "encoding": "UTF-8", "encoding_source": "cpg", "fields": [{"name": "name", "type": "C", "length": 16, "decimals": 0}, {"name": "area_ha", "type": "N", "length": 4, "decimals": 1}, {"name": "opened", "type": "D", "length": 8, "decimals": 0}, {"name": "playground", "type": "L", "length": 1, "decimals": 0}], "files": {"shx": true, "dbf": true, "prj": true, "cpg": true}, "warnings": []}
The schools (windows-1252 from the .cpg)
admin
shp info "tmp/doc_geox/ecoles.shp"
mentdb
{"path": "tmp/doc_geox/ecoles.shp", "geometry_type": "Point", "shape_type": "Point", "z": false, "m": false, "count": 3, "records_from": "shx index", "dbf_records": 3, "deleted_records": 0, "bbox": [55.454, -21.3405, 55.477, -20.88], "z_range": null, "crs": {"epsg": "EPSG:4326", "name": "WGS 84", "source": "prj name"}, "prj_name": "GCS_WGS_1984", "bbox_wgs84": [55.454, -21.3405, 55.477, -20.88], "encoding": "windows-1252", "encoding_source": "cpg", "fields": [{"name": "NOM", "type": "C", "length": 40, "decimals": 0}, {"name": "ELEVES", "type": "N", "length": 6, "decimals": 0}, {"name": "OUVERTURE", "type": "D", "length": 8, "decimals": 0}], "files": {"shx": true, "dbf": true, "prj": true, "cpg": true}, "warnings": []}
A file that does not exist
admin
shp info "tmp/doc_geox/none.shp"
mentdb
ERROR: Sorry, an error appears (the file tmp/doc_geox/none.shp does not exist).
shp read <shp_path>
Description
Read a Shapefile as a GeoJSON FeatureCollection in the CRS of the file (the legacy crs member is written when it is not 4326). Null shapes give a null geometry
Read a Shapefile as a GeoJSON FeatureCollection in the CRS of the file (the legacy crs member is written when it is not 4326). Null shapes give a null geometry
Parameters
shp_path: The .shp file - String - required
shp_path: The .shp file - String - required
admin
shp read "tmp/doc_geox/parcs.shp"
mentdb
{"type": "FeatureCollection", "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::2975"}}, "features": [{"type": "Feature", "properties": {"name": "Parc du Colorado", "area_ha": 14.5, "opened": "1998-06-01", "playground": true}, "geometry": {"type": "Polygon", "coordinates": [[[338000, 7690000], [338400, 7690000], [338400, 7690400], [338000, 7690400], [338000, 7690000]], [[338100, 7690100], [338100, 7690200], [338200, 7690200], [338200, 7690100], [338100, 7690100]]]}}, {"type": "Feature", "properties": {"name": "Jardin de l'Etat", "area_ha": 9, "opened": "1773-01-01", "playground": false}, "geometry": {"type": "Polygon", "coordinates": [[[339000, 7690000], [339300, 7690000], [339300, 7690300], [339000, 7690300], [339000, 7690000]]]}}]}
shp read <shp_path> <json_params>
Description
Read a Shapefile with parameters: format (geojson, or rows: the attributes and a WKT field), geometry_field (wkt), to_crs (transform the coordinates; from_crs gives the CRS when the .prj is missing or unknown), decimals (4 for meters, 9 for degrees after a transformation), encoding (overrides the .cpg), fields (the fields to keep), offset and limit (paging over the records, 1 million by default), max_points (5 million)
Read a Shapefile with parameters: format (geojson, or rows: the attributes and a WKT field), geometry_field (wkt), to_crs (transform the coordinates; from_crs gives the CRS when the .prj is missing or unknown), decimals (4 for meters, 9 for degrees after a transformation), encoding (overrides the .cpg), fields (the fields to keep), offset and limit (paging over the records, 1 million by default), max_points (5 million)
Parameters
shp_path: The .shp file - String - required
json_params: The parameters - String - required
shp_path: The .shp file - String - required
json_params: The parameters - String - required
admin
shp read "tmp/doc_geox/parcs.shp" "{\"to_crs\": \"4326\", \"decimals\": 6}"
mentdb
{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"name": "Parc du Colorado", "area_ha": 14.5, "opened": "1998-06-01", "playground": true}, "geometry": {"type": "Polygon", "coordinates": [[[55.442594, -20.883145], [55.446438, -20.88318], [55.446475, -20.879567], [55.442631, -20.879532], [55.442594, -20.883145]], [[55.443564, -20.88225], [55.443574, -20.881347], [55.444535, -20.881356], [55.444525, -20.882259], [55.443564, -20.88225]]]}}, {"type": "Feature", "properties": {"name": "Jardin de l'Etat", "area_ha": 9, "opened": "1773-01-01", "playground": false}, "geometry": {"type": "Polygon", "coordinates": [[[55.452205, -20.883232], [55.455088, -20.883258], [55.455116, -20.880548], [55.452233, -20.880522], [55.452205, -20.883232]]]}}]}
The schools as rows
admin
shp read "tmp/doc_geox/ecoles.shp" "{\"format\": \"rows\"}"
mentdb
[{"NOM": "Ecole Champ Fleuri", "ELEVES": 312, "OUVERTURE": "1975-09-01", "wkt": "POINT (55.465 -20.892)"}, {"NOM": "Ecole Raphael Babet", "ELEVES": 254, "OUVERTURE": "1982-09-01", "wkt": "POINT (55.477 -21.3405)"}, {"NOM": "Collège Bourbon", "ELEVES": 980, "OUVERTURE": "1961-09-01", "wkt": "POINT (55.454 -20.88)"}]
The schools in RGR92 / UTM 40S, one field, from the second record
admin
shp read "tmp/doc_geox/ecoles.shp" "{\"format\": \"rows\", \"to_crs\": \"2975\", \"fields\": [\"NOM\"], \"offset\": 1, \"geometry_field\": \"geom\"}"
mentdb
[{"NOM": "Ecole Raphael Babet", "geom": "POINT (342064.4097 7639403.5399)"}, {"NOM": "Collège Bourbon", "geom": "POINT (339183.328 7690359.5807)"}]
The roads with an unknown CRS (no .prj): from_crs is needed to transform
admin
shp read "tmp/doc_geox/routes.shp" "{\"to_crs\": \"4326\"}"
mentdb
ERROR: Sorry, an error appears (the CRS of the Shapefile is unknown (no .prj file): give from_crs).
