map

Documentation géospatiale de Talaxie Talaxie Geospatial Documentation

Lisez, transformez et écrivez des données géographiques dans vos jobs : shapefiles, PostGIS, WFS, projections, calculs géométriques. Les composants Talend Spatial, portés vers Java 21 et GeoTools 35, sont livrés avec Talaxie. Read, transform and write geographic data in your jobs: shapefiles, PostGIS, WFS, projections, geometric calculations. The Talend Spatial components, ported to Java 21 and GeoTools 35, ship with Talaxie.

Vue d'ensembleOverview

L'extension Talend Spatial (licence Apache 2.0) ajoutait au Studio des composants géospatiaux, un type de colonne Geometry et des routines. Elle reposait sur GeoTools 8.5, qui ne démarre plus après Java 8. Talaxie livre une version portée vers Java 21, GeoTools 35.2 et JTS 1.20 : rien à installer, les composants sont dans la palette. The Talend Spatial extension (Apache 2.0 license) added geospatial components, a Geometry column type and routines to the Studio. It relied on GeoTools 8.5, which no longer starts after Java 8. Talaxie ships a version ported to Java 21, GeoTools 35.2 and JTS 1.20: nothing to install, the components are in the palette.

widgets

PalettePalette

Famille Geo et ses sous-familles : fichiers, base de données, calculs, manipulations, opérateurs géométriques, collecteurs, qualité, géocodage, métadonnées. Les composants ont l'onglet Composant, l'ajout rapide et la recherche comme ceux de Talaxie. Geo family and its sub-families: files, database, calculators, manipulators, geometric operators, collectors, data quality, geocoding, metadata. The components have the Component tab, quick add and search like the Talaxie ones.

category

Type GeometryGeometry type

Proposé dans la liste des types de tous les schémas (id_Geometry). Une colonne Geometry passe d'un composant à l'autre comme une colonne ordinaire, tMap et tLogRow compris. Offered in the type list of every schema (id_Geometry). A Geometry column goes from one component to the next like any column, tMap and tLogRow included.

functions

Routines

GeometryOperation, GeoOperation, GeometryUtility et OpenStreetMap, utilisables dans toute expression. Une routine n'est jointe qu'au job qui la cite, avec ses bibliothèques. GeometryOperation, GeoOperation, GeometryUtility and OpenStreetMap, usable in any expression. A routine is only added to the job that uses it, with its libraries.

PrérequisRequirements

  • Un JDK 21, comme pour tous les jobs de Talaxie. A JDK 21, as for every Talaxie job.
  • Les bibliothèques (GeoTools, JTS, pilote PostgreSQL…) ne sont pas livrées : Talaxie les prend dans le dépôt Maven local, sinon les télécharge à la première exécution depuis Maven Central et https://repo.osgeo.org/repository/release (GeoTools n'est pas sur Maven Central). Le poste doit alors accéder à ces dépôts, directement ou par un miroir. The libraries (GeoTools, JTS, PostgreSQL driver…) are not shipped: Talaxie takes them from the local Maven repository, otherwise downloads them on the first run from Maven Central and https://repo.osgeo.org/repository/release (GeoTools is not on Maven Central). The machine then needs access to these repositories, directly or through a mirror.
  • Pour les composants PostGIS : PostgreSQL avec l'extension PostGIS (CREATE EXTENSION postgis; dans la base). For the PostGIS components: PostgreSQL with the PostGIS extension (CREATE EXTENSION postgis; in the database).
  • Pour le géocodage et l'altitude : un accès aux services web de GeoNames. For geocoding and elevation: access to the GeoNames web services.

Le type GeometryThe Geometry type

Une colonne de type Geometry contient un objet org.talend.sdi.geometry.Geometry : une géométrie JTS (point, ligne, polygone, collection) et, éventuellement, son système de coordonnées (CRS). Son texte est le WKT de la géométrie : un tLogRow affiche POINT (2.35 48.85). A Geometry column holds an org.talend.sdi.geometry.Geometry object: a JTS geometry (point, line, polygon, collection) and, optionally, its coordinate reference system (CRS). Its text is the geometry WKT: a tLogRow prints POINT (2.35 48.85).

Créer une géométrieCreate a geometry

Depuis un texte WKT, dans un tFixedFlowInput, un tMap ou un tJavaRow : From a WKT text, in a tFixedFlowInput, a tMap or a tJavaRow:

org.talend.sdi.geometry.Geometry.parseGeometry("POINT (2.35 48.85)")
org.talend.sdi.geometry.Geometry.parseGeometry("POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))")

Ou avec le composant sGeomTxtInput, qui produit une ligne à partir d'un WKT, et les composants de lecture (shapefile, PostGIS, WFS). Or with the sGeomTxtInput component, which produces one row from a WKT, and the reading components (shapefile, PostGIS, WFS).

Coordonnées et projectionsCoordinates and projections

  • L'ordre est toujours x = longitude, y = latitude : POINT (2.35 48.85) est Paris en WGS 84 (EPSG:4326). The order is always x = longitude, y = latitude: POINT (2.35 48.85) is Paris in WGS 84 (EPSG:4326).
  • Les systèmes se donnent par leur code EPSG ("EPSG:2154" pour le Lambert 93). La base EPSG de GeoTools est livrée avec les bibliothèques : aucun accès réseau n'est nécessaire. Systems are given by their EPSG code ("EPSG:2154" for Lambert 93). The GeoTools EPSG database comes with the libraries: no network access is needed.
  • setCRS("EPSG:4326"), getCRS(), getSRID() et getEPSG() lisent ou fixent le système d'une géométrie. setCRS("EPSG:4326"), getCRS(), getSRID() and getEPSG() read or set the system of a geometry.

Méthodes de l'objetObject methods

getArea() · getLength() · distance(g)Surface, longueur, distance, dans l'unité du système de coordonnées.Area, length, distance, in the unit of the coordinate system.
buffer(d) · convexHull() · getCentroid() · getInteriorPoint() · getEnvelope() · getBoundary()Géométries dérivées ; le système de coordonnées est conservé.Derived geometries; the coordinate system is kept.
union(g) · intersection(g) · difference(g) · symDifference(g)Opérations ensemblistes.Set operations.
intersects(g) · contains(g) · within(g) · touches(g) · crosses(g) · overlaps(g) · covers(g) · coveredBy(g) · disjoint(g) · relate(g)Prédicats spatiaux (modèle DE-9IM).Spatial predicates (DE-9IM model).
getGeometryType() · getNumPoints() · getNumGeometries() · getGeometryN(n) · getCoordinates() · isValid() · isEmpty()Description de la géométrie.Geometry description.
simplify(type, tolérance)Simplification : "DouglasPeuckerSimplifier" ou "TopologyPreservingSimplifier".Simplification: "DouglasPeuckerSimplifier" or "TopologyPreservingSimplifier".
_getInternalGeometry()La géométrie JTS (org.locationtech.jts.geom.Geometry), pour tout ce que JTS sait faire.The JTS geometry (org.locationtech.jts.geom.Geometry), for anything JTS can do.

Types des bases de donnéesDatabase types

Une colonne Geometry correspond au type GEOMETRY de PostgreSQL (PostGIS) et à MDSYS.SDO_GEOMETRY ou SDO_GEOMETRY d'Oracle. A Geometry column maps to the PostgreSQL (PostGIS) GEOMETRY type and to Oracle MDSYS.SDO_GEOMETRY or SDO_GEOMETRY.

Import de la classeClass import

Le code d'un job nomme la classe Geometry sans son paquet. Les composants Spatial qui lisent ou calculent des géométries ajoutent l'import. Dans un job où une colonne Geometry ne passe par aucun d'eux, ajoutez import org.talend.sdi.geometry.Geometry; dans l'onglet Paramètres avancés › Import d'un tJava. Job code names the Geometry class without its package. The Spatial components that read or compute geometries add the import. In a job where a Geometry column goes through none of them, add import org.talend.sdi.geometry.Geometry; in the Advanced settings › Import tab of a tJava.

ComposantsComponents

Par famille de la palette. Les composants marqués non porté sont livrés tels quels, sans portage ; web appelle un service en ligne ; bac à sable vient du plugin expérimental de Talend Spatial. By palette family. Components marked not ported ship as they were, without porting; web calls an online service; sandbox comes from the experimental Talend Spatial plugin.

FamilleFamily ComposantComponent Description
Geo/File/InputsShapefileInputLit un fichier ESRI Shapefile, objet par objet.Reads an ESRI Shapefile, feature by feature.
sWfsInputLit les objets d'un serveur WFS (versions 1.0.0, 1.1.0, 2.0.0).Reads the features of a WFS server (versions 1.0.0, 1.1.0, 2.0.0).
sGeomTxtInputCrée un objet à partir de sa représentation WKT.Creates a feature from its WKT representation.
sOSMNodesInput · sOSMWaysInputLit un fichier OpenStreetMap et en extrait les nœuds ou les chemins (famille Geo/File/Input/OpenStreetMap).Reads an OpenStreetMap file and extracts its nodes or ways (Geo/File/Input/OpenStreetMap family).
sOgrInput non porténot portedLit une source vecteur par GDAL/OGR.Reads a vector source through GDAL/OGR.
sOGRInfoInput non porténot portedInformations sur un jeu de données vecteur (GDAL/OGR).Information about a vector dataset (GDAL/OGR).
sGdalInfoInput non porténot portedInformations sur un jeu de données raster (GDAL).Information about a raster dataset (GDAL).
sNetCDFInput · sOPeNDAPInput bac à sablesandboxUne ligne par combinaison d'index d'un fichier NetCDF ou d'une source OPeNDAP.One row per index combination of a NetCDF file or an OPeNDAP source.
Geo/File/OutputsShapefileOutputÉcrit un fichier ESRI Shapefile (avec option de métadonnées ISO 19139).Writes an ESRI Shapefile (with an ISO 19139 metadata option).
sGeoRSSOutputÉcrit un flux GeoRSS (GeoRSS simple ou point GML) ; chaque colonne donne l'élément de même nom (title…).Writes a GeoRSS feed (simple GeoRSS or GML point); each column gives the element of the same name (title…).
sOgrOutput non porténot portedÉcrit une source vecteur par GDAL/OGR.Writes a vector source through GDAL/OGR.
Geo/File/ManagementsGeoServerPublisher bac à sablesandboxPublie un shapefile zippé ou un GeoTIFF sur un GeoServer.Publishes a zipped shapefile or a GeoTIFF to a GeoServer.
sThreddsIterator bac à sablesandboxUne ligne par jeu de données accessible d'un catalogue THREDDS.One row per accessible dataset of a THREDDS catalog.
Geo/DatabasesPostgisInputLit une table PostGIS, objet par objet.Reads a PostGIS table, feature by feature.
sPostgisOutputÉcrit une table PostGIS : la table est supprimée puis recréée.Writes a PostGIS table: the table is dropped then recreated.
Geo/CalculatorssAreaCalculatorSurface de la géométrie (colonne area).Geometry area (area column).
sLengthCalculatorLongueur de la géométrie.Geometry length.
sPointsCounter · sGeomsCounterNombre de points, nombre de géométries simples.Number of points, number of simple geometries.
sGetGeomSRIDSRID de chaque géométrie, dans une nouvelle colonne.SRID of each geometry, in a new column.
sCoordinateFetcherCoordonnées x et y du point d'index donné, dans de nouvelles colonnes.x and y coordinates of the point at the given index, in new columns.
sDecimalDegreesCalculatorDegrés décimaux à partir de degrés, minutes et secondes rangés dans des colonnes séparées.Decimal degrees from degrees, minutes and seconds stored in separate columns.
sGetElevation webAltitude d'un point (GeoNames, données GTOPO30 ou SRTM).Elevation of a point (GeoNames, GTOPO30 or SRTM datasets).
Geo/ManipulatorssBufferCalculatorZone tampon, de distance positive ou négative.Buffer, with a positive or negative distance.
sCentroidCalculatorCentroïde.Centroid.
sInsidePointExtractorPoint garanti à l'intérieur de la surface.Point guaranteed to lie inside the area.
sEnvelopeCalculatorEnveloppe (rectangle englobant).Envelope (bounding rectangle).
sConvexHullCalculatorEnveloppe convexe.Convex hull.
sBoundaryReplacerRemplace un polygone par sa limite (une ligne) ; points et lignes inchangés.Replaces a polygon with its boundary (a line); points and lines unchanged.
s2DPointReplacerRemplace la géométrie par un point dont X et Y viennent de deux colonnes.Replaces the geometry with a point whose X and Y come from two columns.
sChangeLineDirectionInverse le sens des lignes.Reverses line direction.
sSimplifySimplification (Douglas-Peucker ou préservation de la topologie), selon une tolérance.Simplification (Douglas-Peucker or topology preserving), with a tolerance.
sTransformTransformation affine : translation, rotation, mise à l'échelle.Affine transformation: translation, rotation, scaling.
sSimpleGeomToMultiPOINT, LINESTRING, POLYGON → MULTIPOINT, MULTILINESTRING, MULTIPOLYGON.POINT, LINESTRING, POLYGON → MULTIPOINT, MULTILINESTRING, MULTIPOLYGON.
sSimplePolygonizerMultipolygone à partir de lignes fermées ; la géométrie d'entrée si elles ne le sont pas.Multipolygon from closed lines; the input geometry when they are not closed.
Geo/Geometric OperatorssProjReprojette les géométries d'un système EPSG vers un autre.Reprojects geometries from one EPSG system to another.
sClipperBoxDécoupe les géométries par un rectangle (intersection).Clips geometries with a rectangle (intersection).
sDissolverFusionne les surfaces adjacentes d'un même groupe.Merges adjacent areas of the same group.
sCascadedPolygonUnionFusionne les surfaces d'un groupe en supprimant les limites communes.Merges the areas of a group by removing common boundaries.
Geo/CollectorssBoundingBoxAccumulatorRectangle englobant de chaque groupe d'objets.Bounding box of each group of features.
sConvexHullAccumulatorEnveloppe convexe de chaque groupe d'objets.Convex hull of each group of features.
sNeighborFinderObjet le plus proche, cherché dans un flux Lookup dont la clé est la géométrie.Nearest feature, searched in a Lookup flow keyed on the geometry.
Geo/Data QualitysGeomValidatorLa géométrie est-elle valide ?Is the geometry valid?
Geo/GeocodingsFindPlaceName webNom du lieu le plus proche (géocodage inverse GeoNames).Nearest place name (GeoNames reverse geocoding).
sFindPostalCode webCodes postaux les plus proches (géocodage inverse GeoNames).Nearest postal codes (GeoNames reverse geocoding).
Geo/MetadatasMetadataCreatorFichier XML de métadonnées ISO 19139.ISO 19139 XML metadata file.
sMEFCreatorFichier au format Metadata Exchange Format (MEF).Metadata Exchange Format (MEF) file.
sCataloguePublisherPublie les métadonnées d'une sortie Spatial dans un catalogue (GeoNetwork).Publishes the metadata of a Spatial output to a catalog (GeoNetwork).
sESRIArcCatalog_to_ISO19115 · sISO19115_to_ISO19139FR · sISO19139_to_ISO19139FR · sISO19139FR_to_ISO19139Conversions XSLT de métadonnées : ArcCatalog d'ESRI, ISO 19115, ISO 19139 et son profil France.XSLT metadata conversions: ESRI ArcCatalog, ISO 19115, ISO 19139 and its French profile.
sCSWRequest bac à sablesandboxEnvoie une requête POST à un serveur CSW.Sends a POST request to a CSW server.

Paramètres des principaux composantsMain component parameters

sShapefileInput · sShapefileOutput

  • Nom du fichier : le .shp ; les .dbf, .shx et .prj sont lus ou écrits à côté.File name: the .shp; the .dbf, .shx and .prj are read or written next to it.
  • Type de géométrie (sortie) : un seul par fichier (POINT par défaut, LINESTRING, POLYGON, MULTI…). Sans CRS forcé, une géométrie d'un autre type arrête le job, et le CRS du fichier est celui de la première géométrie.Geometry type (output): one per file (POINT by default, LINESTRING, POLYGON, MULTI…). Without a forced CRS, a geometry of another type stops the job, and the file CRS is that of the first geometry.
  • Forcer le CRS : impose un code EPSG au lieu de celui du .prj ou des géométries.Force CRS: imposes an EPSG code instead of the one from the .prj or the geometries.
  • Filtre CQL (entrée), ajout et jeu de caractères du DBF (sortie), niveau des journaux de GeoTools (ERROR par défaut).CQL filter (input), append and DBF charset (output), GeoTools log level (ERROR by default).
  • Les noms des colonnes du DBF font au plus 10 caractères.DBF column names are at most 10 characters long.

sPostgisInput · sPostgisOutput

  • Hôte, port, base, schéma, utilisateur, mot de passe, table, et colonne de géométrie ("the_geom" par défaut).Host, port, database, schema, user, password, table, and geometry column ("the_geom" by default).
  • En sortie, la table est supprimée puis recréée à chaque exécution, nom et colonnes en minuscules, avec une clé fid et un index spatial GiST.On output, the table is dropped then recreated on every run, name and columns in lower case, with a fid key and a GiST spatial index.
  • Le type et le SRID de la colonne viennent du type de géométrie et du CRS forcé : POINT et "EPSG:4326" donnent geometry(Point,4326). GEOMETRY (par défaut) crée une colonne sans type précis.The column type and SRID come from the geometry type and the forced CRS: POINT and "EPSG:4326" give geometry(Point,4326). GEOMETRY (default) creates a column without a precise type.

sWfsInput

  • URL du service, version WFS (1.0.0, 1.1.0, 2.0.0) et nom du type d'objet à lire.Service URL, WFS version (1.0.0, 1.1.0, 2.0.0) and feature type name to read.
  • Utilisateur et mot de passe, requêtes POST, délai, taille du tampon, mode tolérant, compression gzip, filtre CQL, CRS forcé.User and password, POST requests, timeout, buffer size, lenient mode, gzip compression, CQL filter, forced CRS.

sProj

  • CRS source ("EPSG:4326" par défaut) et CRS cible.Source CRS ("EPSG:4326" by default) and target CRS.
  • Mode tolérant : accepte une transformation approchée quand les paramètres de changement de datum manquent.Lenient mode: accepts an approximate transformation when datum shift parameters are missing.
  • Transformation personnalisée : fichier de propriétés où 4326,2154=<WKT de la transformation>. Le modèle livré, .spatial/proj/epsg_operations.properties, et la grille ntf_r93.gsb sont copiés dans le workspace au premier job qui s'en sert.Custom transformation: properties file where 4326,2154=<transformation WKT>. The shipped template, .spatial/proj/epsg_operations.properties, and the ntf_r93.gsb grid are copied into the workspace by the first job that uses them.

Routines

Fonctions statiques, appelées par leur classe : GeometryOperation.GETAREA(row1.the_geom). Les géométries sont des Geometry ; celles renvoyées gardent le système de coordonnées de la première. Static functions, called through their class: GeometryOperation.GETAREA(row1.the_geom). Geometries are Geometry objects; returned ones keep the coordinate system of the first.

GeometryOperation

GETAREA(g) · GETLENGTH(g)Surface, longueur (Double).Area, length (Double).
GETNUMPOINTS(g) · GETNUMGEOMETRIES(g) · GETGEOMETRYTYPE(g) · GETSRID(g)Nombre de points, de géométries, type ("Point"…), SRID.Number of points, of geometries, type ("Point"…), SRID.
PROJ(g, "EPSG:4326", "EPSG:2154", lenient)Reprojection d'une géométrie.Reprojects a geometry.
GETCENTROID(g) · GETINTERIORPOINT(g) · GETENVELOPE(g) · GETBOUNDARY(g) · GETCONVEXHULL(g)Géométries dérivées.Derived geometries.
GETBUFFER(g, distance, segments, "ROUND")Zone tampon ; extrémités "ROUND", "SQUARE", "BUTT" ou "FLAT".Buffer; end caps "ROUND", "SQUARE", "BUTT" or "FLAT".
INTERSECTION(g1, g2) · UNION · DIFFERENCE · SYMDIFFERENCEOpérations ensemblistes.Set operations.
EQUALS(g1, g2) · DISTANCE(g1, g2)Égalité, distance.Equality, distance.
GETGEOMETRYN(g, n) · GETCOORDINATE(g, n, "X")n-ième géométrie ; coordonnée X, Y ou Z du n-ième point (-1 : le dernier).n-th geometry; X, Y or Z coordinate of the n-th point (-1: the last one).
SIMPLIFY(g, type, tolérance) · PRECISIONREDUCER(g, décimales)Simplification ; arrondi des coordonnées.Simplification; coordinate rounding.
ISVALID(g) · TOWKT(g)Validité ("true"/"false"), texte WKT.Validity ("true"/"false"), WKT text.

GeoOperation

  • Prédicats : INTERSECTS, TOUCHES, CROSSES, CONTAINS, WITHIN, COVERS, COVEREDBY, DISJOINT, OVERLAPS, tous (g1, g2).Predicates: INTERSECTS, TOUCHES, CROSSES, CONTAINS, WITHIN, COVERS, COVEREDBY, DISJOINT, OVERLAPS, all (g1, g2).
  • RELATE(g1, g2) : matrice DE-9IM ; RELATE(g1, g2, "T*F**FFF*") : test d'une matrice.RELATE(g1, g2): DE-9IM matrix; RELATE(g1, g2, "T*F**FFF*"): matrix test.
  • GETDISTANCE(g1, g2), ISWITHINDISTANCE(g1, g2, d), GETCLOSESTPOINT(g1, g2).GETDISTANCE(g1, g2), ISWITHINDISTANCE(g1, g2, d), GETCLOSESTPOINT(g1, g2).

GeometryUtility · OpenStreetMap

  • GeometryUtility.GMLToGeometry(gml, valider) : géométrie à partir d'un fragment GML 3 (<gml:Point>…).GeometryUtility.GMLToGeometry(gml, validate): geometry from a GML 3 fragment (<gml:Point>…).
  • OpenStreetMap.GETTAGVALUE(tags, "name") : valeur d'une balise dans la colonne des balises lue par sOSMNodesInput ou sOSMWaysInput.OpenStreetMap.GETTAGVALUE(tags, "name"): value of a tag in the tags column read by sOSMNodesInput or sOSMWaysInput.

GeoTools en JavaGeoTools in Java

Les composants Spatial reposent sur GeoTools 35.2 et JTS 1.20. Pour ce qu'ils ne font pas (une autre source, une jointure spatiale, un calcul particulier), un tJava, un tJavaRow ou une routine du projet peut appeler GeoTools directement. Les extraits de cette section ont été exécutés sous Java 21 avec les bibliothèques livrées ; les paramètres PostGIS sont ceux qu'emploie sPostgisInput. The Spatial components rely on GeoTools 35.2 and JTS 1.20. For what they do not do (another source, a spatial join, a specific calculation), a tJava, a tJavaRow or a project routine can call GeoTools directly. The snippets of this section were run on Java 21 with the shipped libraries; the PostGIS parameters are those sPostgisInput uses.

Les notionsKey concepts

DataStoreUne source : un shapefile, une base PostGIS, un service WFS. Toutes se lisent avec la même API ; DataStoreFinder.getDataStore(paramètres) trouve la bonne.A source: a shapefile, a PostGIS database, a WFS service. All are read with the same API; DataStoreFinder.getDataStore(parameters) finds the right one.
SimpleFeatureSource · SimpleFeatureStoreUne couche (fichier, table), en lecture ou en écriture.A layer (file, table), read-only or writable.
SimpleFeatureUn objet : ses attributs (getAttribute("nom")) et sa géométrie (getDefaultGeometry()).A feature: its attributes (getAttribute("nom")) and its geometry (getDefaultGeometry()).
org.locationtech.jts.geom.GeometryLa géométrie JTS : aire, longueur, buffer, intersection, prédicats.The JTS geometry: area, length, buffer, intersection, predicates.
CRS · MathTransform · JTSSystèmes de coordonnées (CRS.decode("EPSG:2154")) et reprojection (JTS.transform).Coordinate reference systems (CRS.decode("EPSG:2154")) and reprojection (JTS.transform).
Filter (CQL)Sélection des objets, en texte : ECQL.toFilter("pop > 1000000"). Sur PostGIS, le filtre devient du SQL exécuté par la base.Feature selection, as text: ECQL.toFilter("pop > 1000000"). On PostGIS, the filter becomes SQL run by the database.

Bibliothèques du jobJob libraries

  • Elles arrivent avec les composants Spatial : dans un job qui en contient un, un tJava ou un tJavaRow a tout GeoTools (shapefile, PostGIS, WFS, CQL, projections).They come with the Spatial components: in a job that contains one, a tJava or a tJavaRow has all of GeoTools (shapefile, PostGIS, WFS, CQL, projections).
  • Un tJava seul qui cite une routine Spatial (GeometryOperation.TOWKT(…)…) a les projections, la base EPSG et JTS, mais pas les formats de fichiers ni de bases.A lone tJava that uses a Spatial routine (GeometryOperation.TOWKT(…)…) has projections, the EPSG database and JTS, but not the file or database formats.

ImportsImports

Les imports se mettent dans l'onglet Paramètres avancés › Import du tJava ; ils valent pour tout le job. N'importez pas org.locationtech.jts.geom.Geometry : les composants Spatial importent déjà org.talend.sdi.geometry.Geometry, le type des colonnes, et le nom Geometry deviendrait ambigu (le job ne compile plus). Écrivez la géométrie JTS avec son nom complet ; import org.locationtech.jts.geom.*; reste possible. Imports go in the Advanced settings › Import tab of the tJava; they apply to the whole job. Do not import org.locationtech.jts.geom.Geometry: the Spatial components already import org.talend.sdi.geometry.Geometry, the column type, and the name Geometry would become ambiguous (the job no longer compiles). Write the JTS geometry with its full name; import org.locationtech.jts.geom.*; is still possible.

Lire un shapefile, avec un filtreRead a shapefile, with a filter

Imports :Imports:

import org.geotools.api.data.*;
import org.geotools.api.feature.simple.*;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.filter.text.ecql.ECQL;

Code :Code:

java.io.File file = new java.io.File("C:/donnees/villes.shp");
DataStore in = DataStoreFinder.getDataStore(java.util.Map.of("url", file.toURI().toURL()));
try {
    SimpleFeatureSource source = in.getFeatureSource(in.getTypeNames()[0]);
    try (SimpleFeatureIterator it = source.getFeatures(ECQL.toFilter("pop > 1000000")).features()) {
        while (it.hasNext()) {
            SimpleFeature f = it.next();
            org.locationtech.jts.geom.Geometry g = (org.locationtech.jts.geom.Geometry) f.getDefaultGeometry();
            System.out.println(f.getAttribute("nom") + " " + g);
        }
    }
} finally {
    in.dispose();   // libère le fichier
}
Paris POINT (2.35 48.85)

Écrire un shapefileWrite a shapefile

En plus des imports précédents :In addition to the previous imports:

import org.geotools.data.DefaultTransaction;
import org.geotools.data.collection.ListFeatureCollection;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.feature.simple.*;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.*;
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
tb.setName("villes");
tb.setCRS(CRS.decode("EPSG:4326", true));
tb.add("the_geom", Point.class);    // buildFeature suit cet ordre
tb.add("nom", String.class);
tb.add("pop", Integer.class);
SimpleFeatureType type = tb.buildFeatureType();

GeometryFactory gf = new GeometryFactory();
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
java.util.List<SimpleFeature> villes = new java.util.ArrayList<>();
villes.add(fb.buildFeature(null, gf.createPoint(new Coordinate(2.35, 48.85)), "Paris", 2100000));
villes.add(fb.buildFeature(null, gf.createPoint(new Coordinate(4.84, 45.76)), "Lyon", 520000));

java.io.File file = new java.io.File("C:/donnees/villes.shp");
DataStore out = new ShapefileDataStoreFactory().createNewDataStore(java.util.Map.of("url", file.toURI().toURL()));
try {
    out.createSchema(type);
    // La couche porte le nom du fichier, pas celui du schéma.
    String typeName = out.getTypeNames()[0];
    SimpleFeatureStore store = (SimpleFeatureStore) out.getFeatureSource(typeName);
    try (Transaction tx = new DefaultTransaction("ecriture")) {
        store.setTransaction(tx);
        store.addFeatures(new ListFeatureCollection(type, villes));
        tx.commit();
    }
} finally {
    out.dispose();
}

Reprojeter et mesurerReproject and measure

import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.locationtech.jts.io.WKTReader;
org.geotools.api.referencing.crs.CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326", true);
org.geotools.api.referencing.crs.CoordinateReferenceSystem l93 = CRS.decode("EPSG:2154", true);
org.geotools.api.referencing.operation.MathTransform versL93 = CRS.findMathTransform(wgs84, l93, true);

org.locationtech.jts.geom.Geometry paris = new WKTReader().read("POINT (2.35 48.85)");
System.out.println(JTS.transform(paris, versL93));

org.locationtech.jts.geom.Geometry carre = new WKTReader().read(
    "POLYGON ((2.35 48.85, 2.36 48.85, 2.36 48.86, 2.35 48.86, 2.35 48.85))");
System.out.println(carre.getArea());                                    // en degrés carrés
System.out.println(Math.round(JTS.transform(carre, versL93).getArea())); // en m²
POINT (652301.5648687112 6861302.730537979)
9.999999999997797E-5
815903

Se connecter à PostGISConnect to PostGIS

Même API et mêmes imports qu'un shapefile ; seuls les paramètres changent :Same API and imports as a shapefile; only the parameters change:

java.util.Map<String, Object> params = new java.util.HashMap<>();
params.put("dbtype", "postgis");
params.put("host", "localhost");
params.put("port", 5432);
params.put("database", "geo");
params.put("schema", "public");
params.put("user", context.pg_user);
params.put("passwd", context.pg_password);
DataStore db = DataStoreFinder.getDataStore(params);
SimpleFeatureSource villes = db.getFeatureSource("villes");

Depuis une colonne GeometryFrom a Geometry column

Dans un tJavaRow, entre le type des colonnes et JTS :In a tJavaRow, between the column type and JTS:

org.locationtech.jts.geom.Geometry g = input_row.the_geom._getInternalGeometry();
output_row.the_geom = new org.talend.sdi.geometry.Geometry(g.buffer(100));
output_row.the_geom.setCRS("EPSG:2154");

PiègesPitfalls

  • Ordre des axes. CRS.decode("EPSG:4326") suit la définition officielle : latitude d'abord. CRS.decode("EPSG:4326", true) met la longitude d'abord, l'ordre des WKT, des shapefiles, de PostGIS et des colonnes Geometry. Gardez true partout.Axis order. CRS.decode("EPSG:4326") follows the official definition: latitude first. CRS.decode("EPSG:4326", true) puts longitude first, the order of WKT, shapefiles, PostGIS and Geometry columns. Keep true everywhere.
  • Unités. Une aire ou une distance est dans l'unité du système : en EPSG:4326, des degrés. Reprojetez d'abord dans un système métrique (Lambert 93 en France) : le carré de 0,01° de l'exemple fait 815 903 m².Units. An area or a distance is in the unit of the system: degrees in EPSG:4326. Reproject to a metric system first (Lambert 93 in France): the 0.01° square of the example is 815,903 m².
  • Nom de la couche. Un shapefile a une seule couche, nommée d'après le fichier : relisez-la avec getTypeNames()[0] après createSchema.Layer name. A shapefile has a single layer, named after the file: read it back with getTypeNames()[0] after createSchema.
  • Fermeture. dispose() sur le DataStore, et fermeture des itérateurs (try (…)), libèrent fichiers et connexions.Closing. dispose() on the DataStore, and closing the iterators (try (…)), release files and connections.
  • Anciens exemples. Un code écrit pour un GeoTools d'avant la version 30 emploie org.opengis.* et com.vividsolutions.jts.* : ici, org.geotools.api.* et org.locationtech.jts.*.Old examples. Code written for a GeoTools older than version 30 uses org.opengis.* and com.vividsolutions.jts.*: here, org.geotools.api.* and org.locationtech.jts.*.

Pour aller plus loin : le guide de GeoTools (tutoriels Quickstart, Feature, CRS) et la javadoc de JTS. To go further: the GeoTools guide (Quickstart, Feature, CRS tutorials) and the JTS javadoc.

ExemplesExamples

Quatre jobs exécutés tels quels avec Talaxie sous Java 21. Chacun commence par un tFixedFlowInput d'une ligne : une colonne nom (String) et une colonne the_geom (Geometry). Four jobs run as is with Talaxie on Java 21. Each starts with a one-row tFixedFlowInput: a nom column (String) and a the_geom column (Geometry).

Surface d'un polygoneArea of a polygon

row1 (Main) row2 (Main) tFixedFlowInput_1 sAreaCalculator_1 tLogRow_1

Valeur de the_geom :the_geom value:

org.talend.sdi.geometry.Geometry.parseGeometry("POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))")

sAreaCalculator ajoute la colonne area (Double) ; le tLogRow affiche nom et area :sAreaCalculator adds the area column (Double); the tLogRow prints nom and area:

Carré|4.0

Projection en Lambert 93Projection to Lambert 93

row1 (Main) row2 (Main) tFixedFlowInput_1 sProj_1 tLogRow_1

Paris en WGS 84, CRS source "EPSG:4326", CRS cible "EPSG:2154" :Paris in WGS 84, source CRS "EPSG:4326", target CRS "EPSG:2154":

org.talend.sdi.geometry.Geometry.parseGeometry("POINT (2.35 48.85)")

Le point sort en mètres, vers x = 652 000 et y = 6 862 000. Sans composant, dans une expression :The point comes out in metres, near x = 652,000 and y = 6,862,000. Without a component, in an expression:

GeometryOperation.PROJ(row1.the_geom, "EPSG:4326", "EPSG:2154", false)

Shapefile écrit puis reluShapefile written then read back

row1 (Main) OnSubjobOk row2 (Main) tFixedFlowInput_1 sShapefileOutput_1 sShapefileInput_1 tLogRow_1
  • Les deux composants : nom de fichier "C:/donnees/villes.shp".Both components: file name "C:/data/villes.shp".
  • sShapefileOutput : type de géométrie POINT.sShapefileOutput: POINT geometry type.
Paris|POINT (2.35 48.85)

Table PostGIS écrite puis reluePostGIS table written then read back

row1 (Main) OnSubjobOk row2 (Main) tFixedFlowInput_1 sPostgisOutput_1 sPostgisInput_1 tLogRow_1
  • Les deux composants : hôte, port, base, schéma "public", utilisateur, mot de passe, table "villes", colonne "the_geom".Both components: host, port, database, "public" schema, user, password, "villes" table, "the_geom" column.
  • sPostgisOutput : type POINT, CRS forcé "EPSG:4326".sPostgisOutput: POINT type, forced CRS "EPSG:4326".
Paris|POINT (2.35 48.85)

Côté base :On the database side:

SELECT nom, ST_AsText(the_geom), ST_SRID(the_geom) FROM villes;
  nom  |     st_astext     | st_srid
-------+-------------------+---------
 Paris | POINT(2.35 48.85) |    4326

Migration depuis Talend Spatial 7.4Migrating from Talend Spatial 7.4

Ce qui reste compatibleWhat stays compatible

  • Les jobs se rouvrent tels quels : mêmes noms de composants, mêmes paramètres, même type id_Geometry.Jobs reopen as they are: same component names, same parameters, same id_Geometry type.
  • Les anciennes valeurs enregistrées sont converties à la génération : types de géométrie com.vividsolutions.jts.geom.Point…, versions WFS org.geotools.data.wfs.protocol.wfs.Version.v1_0_0…Old saved values are converted at generation: geometry types com.vividsolutions.jts.geom.Point…, WFS versions org.geotools.data.wfs.protocol.wfs.Version.v1_0_0…
  • Les routines gardent leurs noms et leurs signatures.Routines keep their names and signatures.

Ce qui changeWhat changes

  • Le code Java d'un tJava ou d'un tJavaRow qui nomme JTS ou GeoTools doit suivre leurs nouveaux paquets : com.vividsolutions.jts → org.locationtech.jts, org.opengis → org.geotools.api, org.geotools.data.DataStore → org.geotools.api.data.DataStore (voir GeoTools en Java).Java code in a tJava or tJavaRow that names JTS or GeoTools must follow their new packages: com.vividsolutions.jts → org.locationtech.jts, org.opengis → org.geotools.api, org.geotools.data.DataStore → org.geotools.api.data.DataStore (see GeoTools in Java).
  • Les journaux de GeoTools passent par java.util.logging ; le niveau choisi dans le composant s'applique toujours.GeoTools logs go through java.util.logging; the level chosen in the component still applies.
  • sShapefileOutput a POINT pour type par défaut (l'ancien défaut, GEOMETRY, n'était pas dans sa liste).sShapefileOutput defaults to the POINT type (the former default, GEOMETRY, was not in its list).
  • WFS 2.0.0 s'ajoute aux versions 1.0.0 et 1.1.0.WFS 2.0.0 is added to versions 1.0.0 and 1.1.0.
  • Les bibliothèques ne sont plus livrées avec les composants : elles se téléchargent (voir les prérequis).Libraries no longer ship with the components: they are downloaded (see the requirements).

Non portésNot ported

  • GDAL/OGR (sOgrInput, sOgrOutput, sGdalInfoInput, sOGRInfoInput) : présents dans la palette mais inutilisables, car ils dépendent encore de GeoTools 8.5 et des bibliothèques natives de GDAL.GDAL/OGR (sOgrInput, sOgrOutput, sGdalInfoInput, sOGRInfoInput): in the palette but unusable, as they still depend on GeoTools 8.5 and on the GDAL native libraries.
  • Bac à sable (sCSWRequest, sGeoServerPublisher, sNetCDFInput, sOPeNDAPInput, sThreddsIterator) : livrés tels quels, sans GeoTools ; leurs bibliothèques anciennes sont prises sur Maven Central.Sandbox (sCSWRequest, sGeoServerPublisher, sNetCDFInput, sOPeNDAPInput, sThreddsIterator): shipped as they were, without GeoTools; their old libraries come from Maven Central.
  • Les assistants de métadonnées Geo et OGR du référentiel, et les composants Sextante.The Geo and OGR metadata wizards of the repository, and the Sextante components.