Geokettle é uma poderosa ferramenta Open Source de ETL – Extração, Transformação e Carga (Extract Transformation and Loading) que automatiza os serviços tanto para o Pentaho – Servidor de Business Intelligence, como para outros fins.
Essa ferramenta tem a capacidade de fazer joins – junções com tabelas de diferentes banco de dados, fazer junções de tabelas espaciais com relacionais, inserir dados de tabelas relacionais em um shapefile exportando-o para um novo shapefile, KML ou transformando-o em uma Análise Espacial – Spacial Analysis, entre outras inúmeras extrações, transformações e cargas.
O GeoKettle pode ser encontrado no seguinte endereço: http://www.spatialytics.org/projects/geokettle/
O exemplo de hoje é uma demonstração de uma junção de uma tabela relacional de um banco de dados PostgreSQL com uma tabela espacial que está em um shapefile com a imagem do Brasil.
Geokettle is a powerful Open Source tool ETL – Extract Transformation and Loading that automates services both for Pentaho – Business Intelligence Server and for other purposes.
This tool has the ability to do joins with tables of different database, perform joins with spatial relational tables, insert data from relational tables in a shapefile exporting it to a new shapefile, KML on turning it into an spatial Analysis, among numerous other extractions, transformations and loads.
The GeoKettle can be found at: http://www.spatialytics.org/projects/geokettle/
Today’s sample is a demonstration of a join from a relational table in a PostgreSQL database with a spacial table that is in a shapefile with the image of Brazil.
Não será usado nenhum repositório para esse exemplo. Depois de iniciar o GeoKettle abrirá a seguinte imagem do programa…
There is no repository used for this sample. After starting the GeoKettle open the following image of the program …
Para começar clique em File → New → Transformation…
To start click File → New → Transformation …
Clique na pasta input para abrir a árvore de opções, clique em Table input e arraste até o painel de trabalho…
Click on the folder tree to open the input options, click Table and drag to the input panel work …
Essa tabela de entrada terá uma conexão com o banco de dados PostgreSQL. Para isso clique duas vezes em cima do ícone e aparecerá a seguinte janela…
This table entry will have a connection to the PostgreSQL database. For this double-click over the icon and the following window …
Nessa nova janela clique no botão New e abrirá uma nova janela para fazer a conexão com o banco de dados.
In this new window click the New button and open a new window to connect to the database.
Insira e selecione os dados correspondente ao banco de dados a ser utilizado, o nome de usuário e a senha e em seguida teste a conexão.
Enter and select the corresponding data to the database being used, the user name and password and then test the connection
Clique agora no botão Get SQL select statement para acessar a tabela de capitais criada na PostgreSQL conforme a imagem a seguir:
Now click the button Get SQL Select Statement to access the table in PostgreSQL capital created in the image below:
Depois de clicar no botão, navegue até a tabela a ser inserida e clique em OK. O GeoKettle irá perguntar se há necessidade de inserir os campos individualmente ou selecionar todos os campos. Neste exemplo vamos selecionar todos.
After clicking the button, navigate to the table to be inserted and click OK. The GeoKettle will ask whether you need to insert the fields individually or select all fields. In this example we select all.
Em seguida verifique se a sua consulta está tudo em ordem e clique em OK para continuar.
Then check if your query is everything in order and then click OK to continue.
O próximo passo será inserir um Shapefile File Input no projeto…
The next step is to insert a Shapefile File Input on the project …
Clique duas vezes sobre o ícone e aparecerá uma janela para selecionar o local onde está o shapefile a ser inserido no projeto. Navegue até o local e selecione-o.
Double-click on the icon and a window to select the location of the shapefile to be inserted in the project. Navigate to the location and select it.
Clique em Open para abrir o arquivo shapefile e clique em OK. Agora o serviço a ser utilizado é o Join Rows (cartesian produtct) porque será feito um join – junção entre a tabela relacional capital do PostgreSQL que tem a coluna com as capitais do Brasil com a tabela espacial do shapefile BRASIL.shp que contém somente os Estados e Regiões.
Click Open to open the shapefile and click OK. Now the service is to use the Join Rows (cartesian produtct) because it will be a join between the capital of the PostgreSQL relational table that has the column with the capital of Brazil with the shapefile spacial table that contains only the BRASIL.shp States and Regions.
Se quiser testar o arquivo shapefile clique duas vezes no componente Shapefile File Input e abrirá novamente a janela de configuração. Clique no botão Preview e abrirá um novo painel…
If you want to test the shapefile double-click the component Shapefile File Input and reopen the configuration window. Click the Preview button and open a new panel …
Selecione a aba Geographic View e abrirá a seguinte aba…
Select the View tab Geographic and open the next tab …
No GeoKettle selecione a pasta Joins e clique para abrir a árvore de opções e escolha o serviço Join Rows (cartesian product) inserindo-o no projeto…
In GeoKettle Joins select the folder and click to open the options tree and select the service Join Rows (cartesian product) inserting it into the project …
Para inserir o primeiro campo para a junção selecione os ícones Table input e o Join Rows …
To insert the first field to select the joint input icons and Join Table Rows …
Clique com o botão de menu, geralmente o direito, no Table input para inserir um novo hop (passo) . Clique em Novo hop e surgirá uma janela para selecionar o hop. No primeiro campo escolha o Table input e no segundo campo selecione o Join Rows conforme a figura…
Click the menu button, usually the right, in the Table to insert a new input hop. Click New hop and a window will pop up to select the hop. In the first field choose the second Table Input field and select the Join rows as pictured …
Aparecerá o primeiro passo e primeiro campo do join…
You will see the first step and join the first field …
Agora é só repetir os passos com o Shapefile File Input selecionando-o junto com o Join Rows para preencher o segundo campo do join…
Now just repeat the steps with the Shapefile File Input by selecting it with the Join rows to fill the second field of the join …
Clique com o botão de opções e selecione a opção Novo hop. Na janela selecione o Shapefile File Input no primeiro campo e o Join Rows no segundo campo e clique em OK.
Click the Options button and select New hop. In the window select the Shapefile File Input Join field and in the first rows in the second field and click OK.
Aparecerá o segundo passo e o segundo campo a ser preenchido no Join…
You will see the second step and the second field to be filled in Join
Agora é a hora de fazer o join – junção das duas tabelas. Clique duas vezes no componente Join Rows (cartesian product) e abrirá uma janela de configuração. Ao selecionar o primeiro campo para fazer o join abrirá uma nova janela mostrando todos os campos das duas tabelas para selecionar as colunas que serão a chave primária da tabela relacional do PostgreSQL e a chave estrangeira da tabela espacial do shapefile. Nesse primeiro campo selecione o campo ‘ufe’ da tabela relacional que será a chave primária da relação e clique em OK…
Now is time to join the two tables. Double-click the component Join Rows (cartesian Product) and opens a configuration window. When you select the first field to make the join a new window will open showing all the fields from both tables to select the columns that will be the primary key of the PostgreSQL relational table and the foreign key spacial table shapefile. In the first field select the field ‘ufe’ the relational table that is the primary key of the relationship and click OK …
Para o segundo campo escolha o campo da tabela espacial ‘UF’ como a chave estrangeira da relação.
For the second field select the field in the spacial table ‘UF’ as the foreign key relationship.
Feche a janela depois que o join esteja corretamente configurado.
Close the window after the join is correctly configured.
A saída da transformação será um arquivo shapefile (novo) e um arquivo kml para visualização no Google Earth. Para isso é preciso clicar na pasta Output que abrirá a árvore de opções de saída do GeoKettle. Clique no ícone KML File Output e insira-o na área de serviço.
The output of the transformation will be a shapefile (new) and a kml file for viewing in Google Earth. To do this you must click on the folder that will open the Output tree GeoKettle output options. Click the File Output KML and insert it in the service area.
Clique também no ícone Shapefile File Output e insira-o também na área de serviço…
Clique também no ícone Shapefile File Output e insira-o também na área de serviço…
Para configurar os arquivos de saída é necessário dar dois cliques em cima do arquivo para configurá-los. Primeiro vamos configurar o KML File Output. Depois de clicar sobre o componente abrirá uma janela de configuração do nome do componente e o local onde será salvo o arquivo de saída. Selecione o local de saída, um nome para o arquivo com a extensão .kml e em seguida clique em open fechando a primeira janela e depois se tudo estiver correto feche a janela de configuração do componente clicando em OK.
To set the output files you need to double click over the file to configure them. First we will set the KML File Output. After clicking on the component opens a configuration window component name and the location where you saved the output file. Select the output location, a name for the file with a. Kml and then click open by closing the window first and then if everything is correct close the configuration window by clicking OK.
O passo seguinte será repetir os mesmos comandos para o componente Shapefile File Output...
The next step will be to repeat the same commands for the component Shapefile File Output …
Finalmente chegou a hora de criar os passos de saída. Selecione os componentes Join Rows e KML Output File…
Finally it´s time to create the output steps. Join Rows Select components and KML File Output …
Clique com o botão de opção do mouse (geralmente o botão direito) e abrirá o menu de opções. Clique em Novo hop e abrirá a janela de configuração. No primeiro campo selecione o componente Join Row e no segundo campo selecione o KML File Output…
Click the option button of the mouse (usually right) and open the options menu. Click New hop and open the configuration window. In the first field select the component Join Row and in the second field select the KML File Output …
O próximo passo é fazer o mesmo com o componente Shapefile File Output: Selecione o Join Rows e o Shapefile File Output…
The next step is to do the same with the component Shapefile Output File: Select the Join Rows Shapefile and File Output …
Clique com o botão de opções no componente Join Rows e abrirá o menu de opções. Clique em New hop e no primeiro campo escolha o componente Join Rows e no segundo campo escolha o componente Shapefile File Output.
Click the option button component in Join Rows and open the options menu. Click New and hop in the first field choose the Rows Join component in the second field and select the File Output Shapefile component.
Esse pequeno exemplo de transformação e carga está finalmente pronto para ser usado. Clique no botão de execução para executar o serviço…
This small sample´s transformation, and loading is finally ready for use. Click the run button to run the service …
E clique no botão Launch para prosseguir com a execução…
And click the Launch button to execute…
Os arquivos de saídas serão gerados nos locais selecionados nas configurações…
The output file will be generated at the locations selected in the settings …
Teste a abra os arquivos kml e shapefile para confirmar os resultados…
Test the open shapefile and kml files to see the results …
Abra a tabela do shapefile e confira o join que foi criado…
Open the table and check the join shapefile that was created …
Para saber mais: http://wiki.spatialytics.org/doku.php?id=projects:geokettle
Thank you for this GeoKettle overview!
We’ve tweeted about it : http://twitter.com/#!/Spatialytics/status/132236019675316224
I´m glad for your tweet. Thank you very much.
Grato pela dica