Question

Manipulating CSV Geometry?

  • 18 June 2014
  • 4 replies
  • 18 views

Hi all,

 

 

I have a CSV with a field containing SDO Geometry. In order to feed this into a database I need to use the chopper transformer to simplify the polygons and the GeometryExtractor to change the geometry from SDO to OGC WKT.

 

 

I can't get this to work on the CSV, I can load the CSV into a GIS program like ARC or QGIS before hand, export it as a shapefile and then do the transformations on the shapefile, but this is an annoying work around and in the long run will take too much time.

 

 

Do you guys know of a way I can do this all in FME? Is there a way I can chop and extract the geometry without having to create a shapefile first?

 

 

Many thanks,

 

 

Rob.

4 replies

Badge +3
Hi,

 

 

You basically said what to do, so i'd say "Yes you can!'.

 

 

csv reader toread the csv, identify geometry column in the reader, generalizer to simplify poly's and geometryreplacer to set to OGC WKT.

 

 

You summed up the procedure yourself... almost literally
Gio,

 

 

Sorry for being a bit dense, but how do I identify the geometry column in the reader? I'm looking through the parameters and don't see that option.

 

 

Furthermore do you have any tips for formatting the Generalizer? It's very important that my polygons have no more than 1500 vertices.

 

 

Thanks

 

Badge +3
No need ot call yourself dense..

 

 

If  the field contains a full sdo geomtery like you need to identiify the geometry type.(circle, polygon, rectangel etc.)

 

Then u can use the SDO_ORDINATE_ARRAY to create the object.

 

U can use these techniques wich are mentioned on FMEpedia:

 

 

Turning Text Data into Spatial FeaturesBack to Top

 

CSV files often contain spatial data listed as a series of X/Y coordinates. To turn these non-geometry fetures (records) into spatial features you must use FME transformers.

 

 

    To get point features: •Use a 2dPointReplacer transformer to replace each record with a point feature using X/Y or Lat/Long values stored in attributes to create the coordinate of the point.

 

•Each point feature retains all the attributes of the original non-geometry feature.

 

•For 3d features use a 3dPointReplacer

 

 

    To get line features is a two-step process: •Turn the records into point features using the process described above

 

•Use a PointConnector transformer to turn the points into a line.

 

•Optionally specify an attribute carrying the line ID number as a way to break the features at the start of each line

 

 

    To get polygon (area) features: •Turn the records into line features using the process described above

 

•If the last point is the same as the first then an area feature is automatically created

 

 

http://fmepedia.safe.com/articles/How_To/Using-FME-to-read-or-write-Comma-Separated-Value-CSV-data

 

 

 

For generalizing the polygons, i assume you want to reduce vertexcount while staying true.

 

If u use the help on this transformer and select the generalizing algorithms, you get a good explanation. 

 

There are examples in the knowledge base too ofcourse.

 

Badge +3
of course i do not know how your csv looks.

 

 

Is the field a full sdo string? Llike

 

SDO_GEOMETRY(2003, NULL, NULL,SDO_ELEM_INFO_ARRAY(1,1003,1),SDO_ORDINATE_ARRAY(3,3, 6,3, 6,5, 4,5, 3,3))

 

 

(this is what i assumed)

 

then you need to parse the string to get at the info.

 

 

Or do you just have comma seperated values? Where each polygon is seperated by a blank line?

 

In latter case this example (old but still valid) may be of use to you. (apart from the shap writing that is.)

 

http://dominoc925.blogspot.nl/2009/04/example-creating-polygons-from-csv-text.html

 

Reply