Import shapefile attributes - how to?

Five Stars

Import shapefile attributes - how to?

Hi everyone, 
I am using the spatial plug-ins to perform the following task.  I have a dataset with X and Y coordinates.  I have also a shapefile with multi polygons and two metadata attributes, name and Id. The idea is to look-up the names in the shapefile with the coordinates.  With a point in polygon it will be determined to which polygon belongs a point. 
I am using the shapefile input component which points to the  .shp file. 
I am facing to hurdles :
- I cannot retrieve the name and I'd from the file.  I can only see an attribute call the_geom. How can I read the metadata? 
- The second thing is, the file contains a multi polygon and I don't know how to iterate over it in order to perform a Contains or intersect with the points.
Any comment will be highly appreciated. 
Kind regards, Paul 
One Star Fxp
One Star

Re: Import shapefile attributes - how to?

Hi, 
you could probably download the demo workspace https://github.com/talend-spatial/workspace-demo-spatial which contains some tMap making spatial join (eg. https://github.com/talend-spatial/workspace-demo-spatial/tree/6.x/DEMO-SPATIAL/process/Spatial/test_....
HTH
Francois
Five Stars

Re: Import shapefile attributes - how to?

Hi Francois, 
thanks for the quick answer. The demo workspace is the right one for the version of the plugins I downloaded. I have downloaded another version which didn't help me. 
Now it seems to work, at least I had a looked at how to create a shapefile schema in the metadata repository and I am able to see not only the geometry but also the others attributes. I hope I can have enough time to post my complete solution. 
Great tools by the way Smiley Happy
Kind Regards, 
Paul.
Five Stars

Re: Import shapefile attributes - how to?

Hi, I solved almost everything. I want to briefly share my solution with you:
1) Create a generic schema under metadata:


2) This is the job overview:

3) I read the shape file using a sShapeFileInput component:

4) The shapefile contains multipolygons and I want to have polygons. My solution was to use a sSimplify component. I used the default settings.
5) The projection of the shapefile was "MGI / Austria Lambert" which corresponds to EPSG 31287. I want to re-project it as EPSG 4326 (GCS_WGS_1984) which is the one used by my input coordinates.
6)  I read the x, y coordinates from a csv file.

7) With a s2DPointReplacer I converted the x,y coordinates as Point(x,y)

This part was tricky, I needed to swap the x, y assignment to x = Latitude and y = longitude because the points in the polygons have this format --> Point(lat, long)
8)Finally I created an expression in a tMap just to get the polygon, poin intersection. I guess a contains would also work:
 
I hope this helps someone else.
Kind regards, 
Paul

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now