Geospatiale II is a 2nd-generation coordinate/file GIS conversion platform for Naissance, with a particular focus on converting visualised web instances and coordinate systems, particularly GeoJSON/Leaflet/Maptalks/Naissance/Turf.js, with Naissance referring to array-compatible GeoJSON coordinates. It is considered to be part of Universal Framework and the broader Geospatiale ecosystem. GeoJSON functions as the master CRS, between which differing formats are converted.
Conversion functions in this regard are generally split into coordinate and geometry conversions, where geometry conversions convert both coordinates/geometry into geometries, whilst coordinates convert only coordinates/geometry into coordinates. Because of this, the following datatypes are given and documented. In addition, Turf.js bindings have been added for Geospatiale II.
‘geojson_coords’ - Raw .geometry for GeoJSON elements.
- coords: (Array<Array<Array<Number, Number>/Number, Number>>)
- type: (String) - A Geometry type. ‘MultiPolygon’ by default, though it may also be ‘LineString’/'Point'.
‘geojson_geometry’ - The main Feature (not just .geometry) for GeoJSON elements.
- (Object):
- type: (String) - ‘Feature’ by default.
- properties: (Object)
- geometry: (Object)
- coordinates: (Array<Array<Array<Number, Number>/Number, Number>>)
- type: (String) - A Geometry type. ‘MultiPolygon’ by default, though it may also be ‘LineString’/'Point'.
‘leaflet_coords’
- (Array<Array<Array<Object>>>):
- (Object):
- lat: (Number)
- lng: (Number)
‘leaflet_geometry’
- L.Polygon: (Object): - MultiPolygon by default.
- ._latlngs: (Array<Array<Array<Object>>>):
- (Object):
- lat: (Number)
- lng: (Number)
- options: (Object)
‘maptalks_coords’
- (Array<Object>):
- (Object):
- x: (Number)
- y: (Number)
- z: (Number) - Undefined by default.
‘maptalks_geometry’
- (Object):
- _coordinates: (Array<Object>): - Determines single polygon coordinates. Does not exist for non-contiguous geometries.
- (Object):
- x: (Number)
- y: (Number)
- z: (Number) - Undefined by default.
- _holes: (Array<Array<Object>>) - Determines enclaves or unrelated holes. Does not exist for non-contiguous geometries.
- (Object):
- x: (Number)
- y: (Number)
- z: (Number) - Undefined by default.
- _geometries: (Object)
- (…) - Self-referential. Contains multiple Polygon geometries inside of it for non-contiguous geometries. Does not exist for contiguous geometries.
- properties: (Object)
- _symbol: (Object) - Controls display styling for Maptalks geometries.
‘naissance_coords’
- Array<Array<Array<Number, Number>>> - Array-compatible GeoJSON coords.
‘naissance_geometry’ - Used to express Naissance geometries in history frames only. Actual rendered Naissance instances are of type maptalks_geometry
.
- (Object):
- coords: (Array<Array<Array<Number, Number>>>)
- options: (Object) - Rendered in .properties as a Maptalks instance.
‘turf_coords’
- Array<Array<Number, Number>>
‘turf_geometry’
- (Object):
- coordinates: (Array<Array<Number, Number>>
- type: (String) - ‘polygon’/'multiPolygon'.
GIS Conversion. Most GIS conversion functions are inherited from Geospatiale I, with a special emphasis on .asc/.geotiff/.geojson/.nc/.png/.tif formats.
GeoPNG 32-bit int (Decode function per pixel):
global.decodeRGBAAsNumber = function (arg0_rgba) {
//Convert from parameters
var rgba = arg0_rgba;
//Declare local instance variables
var r = rgba[0];
var g = rgba[1];
var b = rgba[2];
var a = rgba[3];
//Return statement (rebuild 32-bit integer)
return ((r << 24) | (g << 16) | (b << 8) | a) >>> 0;
};
GeoPNG 32-bit int (Encode function per pixel):
function encodeNumberAsRGBA (arg0_number) {
//Convert from parameters
var number = returnSafeNumber(Math.round(arg0_number));
//Declare local instance variables
var r = (number >> 24) & 0xFF; //Extract highest 8 bits
var g = (number >> 16) & 0xFF; //Extract next 8 bits
var b = (number >> 8) & 0xFF; //Extract next 8 bits
var a = number & 0xFF; //Extract lowest 8 bits
//Return statement
return [r, g, b, a];
};
- convertASCToPNG() - Converts an .asc file to .png.
- arg0_input_file_path: (String)
- arg1_output_file_path: (String)
- arg2_options: (Object)
- is_sedac_convert_intl_dollars: (Boolean) - Optional. Whether this is SEDAC (G-Econ, Kummu et al.). If true, converts from 2011$ to 2000$.
- mode: (String) - Optional. Either ‘number’/'percentage'. ‘number’ by default.
- Returns: (Object)
- dataframe: (Array<Array<Number>>)
- max_value: (Number)
- processHYDEASCsToPNG() - Converts all HYDE .asc files to .png.
- arg0_input_folder: (String)
- arg1_output_folder: (String)
- arg2_options: (Object)
- (…) - Optional. Passed onto convertASCToPNG().
- processSEDACASCsToPNG() - Converts all SEDAC G-Econ .asc files to .png.
- arg0_input_folder: (String)
- arg1_output_folder: (String)
- arg2_options: (Object)
- (…) - Optional. Passed onto convertASCToPNG().
- readASCFile() - Reads an .asc file, returning the dataframe as a 2D array.
- arg0_file_path: (String)
- Returns: (Array<Array<Number>>)
- loadCSVAsArray() - Loads a .csv file as a 2D array.
- Returns: (Array<Array<String>>)
- geoJSONFillPolygon() - Fills a GeoJSON Polygon on a given RGBA buffer.
- arg0_rgba_buffer: (Buffer<ArrayBuffer>)
- arg1_polygon: (Object) - Must be a GeoJSON MultiPolygon/Polygon.
- arg2_options: (Object)
- height: (Number) - Optional. The height of the underlying RGBA buffer. 2160 by default (5-arcmin).
- width: (Number) - Optional. The width of the underlying RGBA buffer. 4320 by default (5-arcmin).
- Returns: (Buffer<ArrayBuffer>)
- getEquirectangularCoordsPixel() - Fetches the x, y coordinate pair for a given pixel based on latitude and longitude coordinates for WGS84 Equirectangular.
- arg0_latitude: (Number)
- arg1_longitude: (Number)
- arg2_options: (Object)
- return_object: (Boolean) - Optional. Whether to return a structured object instead. False by default.
- Returns: (Array<Number, Number>/Object):
- x_coord: (Number)
- y_coord: (Number)
- GHSLGeoJSONToRaster() - Writes a GHSL (Global Human Settlement Layer) GeoJSON file to raster. Note that this can be fetched from the web visualiser tool on Copernicus, but not academic datavaults.
- arg0_input_file_path: (String)
- arg1_output_file_path: (String)
- arg2_options: (Object)
- height: (Number) - Optional. The height of the underlying RGBA buffer. 2160 by default (5-arcmin).
- width: (Number) - Optional. The width of the underlying RGBA buffer. 4320 by default (5-arcmin).
- property: (String) - Optional. The GHSL property to target when determining colour IDs. Corresponds to urban area IDs by default ('ID_UC_G0').
- getImageSum() - Fetches the total sum of all int values within an image.
- arg0_file_path: (String) - The file path to the image to fetch the sum of.
- Returns: (Number)
- getRGBAFromPixel() - Fetches the RGBA value of a pixel based on its index.
- arg0_image_object: (Object)
- arg1_index: (Number)
- Returns: (Array<Number, Number, Number, Number>)
- loadImage() - Loads an image into the assigned value.
- arg0_file_path: (String)
- Returns: (Object)
- loadNumberFromPixel() - Loads an int value from a pixel based on its index.
- arg0_image_object: (Object)
- arg1_index: (Number)
- Returns: (Number)
- loadNumberRasterImage() - Loads a number raster image into the assigned variable.
- arg0_file_path: (String)
- Returns: (Object)
- data: (Array<Number>)
- height: (Number)
- width: (Number)
- operateNumberRasterImage() - Runs an operation on a raster image for a file.
- arg0_options: (Object)
- file_path: (String) - The file path to save the image to.
- function: (Function) - (arg0_index, arg1_number)
- arg0_index: (Number) - The linear index currently being iterated over.
- arg1_number: (Number) - The input number from the GeoPNG.
- Returns: (Number) - Optional. The new number to set for the given GeoPNG. 0 by default.
- saveNumberRatserImage() - Saves a number raster image to a file.
- arg0_options: (Object)
- file_path: (String) - The file path to save the image to.
- height: (Number) - Optional. The height of the image to save. 1 by default.
- width: (Number) - Optional. The width of the image to save. 1 by default.
- function: (Function) - (arg0_index)
- arg0_index: (Number) - The linear index currently being iterated over.
- Returns: (Number) - Optional. The new number to set for the given GeoPNG. 0 by default.
- savePercentageRasterImage() - Saves a percentage raster image to a file based on a number raster image with a step resolution of 0,5%.
- arg0_input_file_path: (String) - The file path to the number raster image to save the percentage raster image from.
- arg1_output_file_path: (String) - The file path to save the percentage raster to.
- Returns: (Object)
- saveNumberToPixel() - Saves an int value to a pixel based on the corresponding index.
- arg0_image_object: (String/Object, GeoPNG) - The image file/object to use.
- arg1_index: (Number) - The index of the pixel to save the number to.
- arg2_number: (Number) - The number to save to the pixel.
- Returns: (Array<Number, Number, Number, Number>) - RGBA code.
- convertNCToASC() - Converts a .nc file to a .asc file, depending on its options.time_index and options.variable_key.
- arg0_input_file_path: (String)
- arg1_output_file_path: (String)
- arg2_options: (Object)
- time_index: (Number) - Optional. 0 by default.
- variable_key: (String) - The variable key to write to a .asc file, as it can only store one value per .asc file.
- getNCVariables() - Fetches all variables present within a .nc file.
- arg0_input_file_path: (String)
- Returns: (Array<String>)
- processSEDAC() - Proces G-Econ SEDAC files, or Kummu-extended G-Econ SEDAC-based files.
- arg0_input_file_path: (String) - The input .nc file to convert to a series of .asc files.
- arg1_output_folder: (String)
- arg2_variable_key: (String) - The variable key to process within SEDAC data.
- convertGeoTIFFToPNG() - Attempts to convert a given GeoTIFF file to GeoPNG, assuming that it is single-band.
- arg0_input_file_path: (String)
- arg1_output_file_path: (String)
- Returns: (Object, PNG)
- downscaleGeoTIFF() - Downscales a GeoTIFF file to a given options.height, options.width resolution.
- arg0_input_file_path: (String) - The input file path.
- arg1_output_file_path: (String) - The output file path.
- arg2_options: (Object)
- height: (Number) - Optional. 2160 by default (5-arcmin).
- width: (Number) - Optional. 4320 by default (5-arcmin).
Web Conversion.
- getCoordsType() - Returns the coords/geometry format the variable represents.
- arg0_format: (Variable) - The coords/geometry format to input.
- Returns: (String) - Either 'geojson_coords'/'geojson_geometry'/'leaflet_coords'/'leaflet_geometry'/'maptalks_coords'/'maptalks_geometry'/'naissance_coords'/'naissance_geometry'/'turf_coords'/'turf_object'.
- convertToGeoJSONCoords()
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('geojson_coords')
- convertToGeoJSONGeometry() - In specification.
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('geojson_geometry')
- convertToLeafletCoords()
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('leaflet_coords')
- convertToLeafletGeometry() - In specification.
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('leaflet_geometry')
- convertToMaptalksCoords()
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('maptalks_coords')
- convertToMaptalksGeometry() - In specification.
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('maptalks_geometry')
- convertToNaissanceCoords()
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('naissance_coords')
- convertToNaissanceGeometry() - In specification.
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('naissance_geometry')
- convertToTurfCoords()
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('turf_coords')
- convertToTurfGeometry()
- arg0_format: (Variable) - Any valid datatype listed in 1. Datatypes.
- Returns: ('turf_geometry')
A number of internal helper functions are made available across Geospatiale II for internal analysis and developer use. They are not necessarily recommended for end developer use, but have been made public in the interests of other developers.
- convertLeafletCoordsToGeoJSONCoords() - Converts Leaflet coords to GeoJSON .geometry.coordinates. Note that this is different from 'geojson_coords', which is .geometry, and not .geometry.coordinates.
- arg0_coords: (Array<Array<Array<Number, Number>>>/Array<Array<Number, Number>>)
- Returns: (Array<Array<Array<Number, Number>>>/Array<Array<Number, Number>>)
- convertLeafletCoordsToMaptalksCoords() - Converts Leaflet coords to Maptalks coords.
- arg0_coords: (Array<Array<Array<Object>>>/Array<Array<Object>>)
- (Object):
- lat: (Number)
- lng: (Number)
- Returns: (Array<Object>)
- (Object):
- x: (Number)
- y: (Number)
- z: (Number)
- convertLeafletCoordsToTurfGeometry() - Converts Leaflet geometry to Turf geometry.
- arg0_geojson: (Object)
- Returns: (Array<Array<Array<Number, Number>>>, String) - [0] contains turf_coords; [1] represents either ‘Polygon’/'MultiPolygon'.
- convertMaptalksGeometryToTurfGeometry() - Converts Maptalks geometry to Turf geometry.
- arg0_coords: (Object)
- Returns: (Array<Array<Array<Number, Number>>>, String) - [0] contains turf_coords; [1] represents either ‘Polygon’/'MultiPolygon'.
- convertNaissanceGeometryToMaptalksCoords() - Converts Naissance geometry to Maptalks coords.
- arg0_entity_id: (Object/String) - The Naissance Geometry ('Entity' in Naissance nomenclature) to convert.
- Returns: (Array<Array<Array<Number, Number>>>/Array<Array<Number, Number>>)
- flipCoordinates() - Flips any _coords type from latlng to lnglat and vice versa. May be arbitrarily nested. Must be GeoJSON compatible.
- arg0_coords: (Variable)
- Returns: (Array<Array<Array<Number, Number>>>/Array<Array<Number, Number>>)
- getLeafletGeoJSONCoords() - Fetches GeoJSON coords from a Leaflet GeoJSON object.
- arg0_geojson: (Object)
- Returns: (Array<Array<Array<Number, Number>>>/Array<Array<Number, Number>>
- isGeoJSONCoords() - Whether the coords type being tested are loosely GeoJSON compatible.
- arg0_coords: (Variable)
- Returns: (Boolean)
- isGeoJSONStrictCoords() - Whether the coords type being tested are strictly GeoJSON compatible.
- arg0_coords: (Variable)
- Returns: (Boolean)
- isValidCoordinate() - Whether the coordinate pair is valid (GeoJSON compatible) and within latitudinal/longitudinal bounds.
- arg0_coords: (Variable)
- Returns: (Boolean)
Requires Turf.js.
- isValidTurfOperation() - Whether the Turf operation is valid. Requires both types to be of turf_geometry.
- arg0_format: (Object)
- arg1_format: (Object)
- Returns: (Boolean)
- performTurfOperation() - Performs a Turf operation similar to difference(), intersect() or union()
- arg0_format: (Object)
- arg1_format: (Object)
- arg2_options: (Object)
- operation_type: (String) - ‘difference’/'intersect'/'union'. Select one of three.
- return_leaflet: (Boolean) - Optional. Whether to return a Leaflet object. True by default.
- buffer() - Buffers a polygon of any acceted format.
- arg0_format: (Variable)
- arg1_options: (Object)
- <key>: (Variable) - Any other value used in turf.buffer()
- radius: (Number) - Optional. The number of units to buffer by. 1 by default.
- return_leaflet: (Boolean) - Optional. Whether to return a Leaflet object. True by default.
- Returns: (Object)
- bufferAll() - Same options as buffer().
- arg0_format_list: (List<Variable>)
- arg1_options: (Object)
- Returns: (List<Variable>)
- difference() - Subtracts arg1_format from arg0_format.
- arg0_format: (Variable)
- arg1_format: (Variable)
- arg2_options: (Object)
- return_leaflet: (Boolean) - Optional. Whether to return a Leaflet object. True by default.
- Returns: (Object)
- differenceAll() - Same options as difference(). First element is subtracted by the rest.
- arg0_format_list: (List<Variable>)
- arg1_options: (Object)
- Returns: (List<Variable>)
- intersection() - Returns the intersection of arg0_format and arg1_format.
- arg0_format: (Variable)
- arg1_format: (Variable)
- Returns: (Object)
- return_leaflet: (Boolean)
- intersectionAll() - Same options as intersection(). The intersection of all elements is returned.
- arg0_format_list: (List<Variable>)
- arg1_options: (Object)
- Returns: (List<Variable>)
- simplify() - Simplifies a polygon of any accepted format.
- arg0_format: (Variable)
- arg1_tolerance: (Number)
- arg2_options: (Object)
- <key>: (Variable) - Any other value used in a turf.simplify()
- return_leaflet: (Boolean) - Optional. Whether to return a Leaflet object. True by default.
- Return: (Object)
- simplifyAll() - Same options as simplify().
- arg0_format_list: (List<Variable>)
- arg1_options: (Object)
- Returns: (List<Variable>)
- union() - Adds arg1_format to arg0_format.
- arg0_format: (Variable)
- arg1_format: (Variable)
- arg2_options: (Object)
- return_leaflet: (Boolean) - Optional. Whether to return a Leaflet object. True by default.
- Returns: (Object)
- unionAll() - Same options as union().
- arg0_format_list: (List<Variable>)
- arg1_options: (Object)
- Returns: (List<Variable>)