using vrt files to import odbc, csv

19
© 2011 Bentley Systems, Incorporated 1 | WWW.BENTLEY.COM Using VRT Files to Import ODBC, CSV Problem: Many data sources come in comma delimited or in Excel or database formats Solution: VRT files describe the data source so they can be easily imported into Bentley Map Notes: Works best with point features Capitalization is important in the various parameters

Upload: truman

Post on 08-Jan-2016

33 views

Category:

Documents


1 download

DESCRIPTION

Using VRT Files to Import ODBC, CSV. Problem : Many data sources come in comma delimited or in Excel or database formats Solution : VRT files describe the data source so they can be easily imported into Bentley Map Notes: Works best with point features - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

1 | WWW.BENTLEY.COM

Using VRT Files to Import ODBC, CSV

• Problem: Many data sources come in comma delimited or in Excel or database formats

• Solution: VRT files describe the data source so they can be easily imported into Bentley Map

• Notes:– Works best with point features– Capitalization is important in the

various parameters

Page 2: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

2 | WWW.BENTLEY.COM

What is VRT (Virtual Datasource)

• An XML format file that describes the format of the source data– Data source– Feature name– Spatial Reference System– Field encoding

Sample VRT<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Page 3: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

3 | WWW.BENTLEY.COM

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Common Parts of VRT fileName of feature

Page 4: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

4 | WWW.BENTLEY.COM

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Common Parts of VRT file

Source for feature

Page 5: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

5 | WWW.BENTLEY.COM

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Common Parts of VRT file

Feature Type

Page 6: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

6 | WWW.BENTLEY.COM

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Common Parts of VRT file

Spatial Reference

Page 7: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

7 | WWW.BENTLEY.COM

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Common Parts of VRT file

Encoding (Column names containing

XY(Z) values)

Page 8: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

8 | WWW.BENTLEY.COM

CSV Example

Source Data: SurveyMon.csv

Easting,Northing,ID,Elevation

602639.5381,4049623.398,1,282.9576447

669949.1987,4061243.25,2,282.3723275

617433.4852,4004901.709,3,265.455676

640922.0652,4096213.903,4,228.7933358

680351.1314,4008944.322,5,211.2217422

689200.8667,4010622.815,6,278.4353313

600382.0976,4086158.497,7,203.1683236

630393.1237,4095834.27,8,262.3779305

644160.8595,4016882.563,9,261.6596222

660532.9288,4092362.074,10,243.4360725

VRT File

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>SurveyMon.csv</SrcDataSource>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Page 9: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

9 | WWW.BENTLEY.COM

The Map Interoperability Tool

• File -> Map Interoperability

• Import -> New Import

• Add file…

• Set All File Types

• Show Properties -> Ungrouped

Page 10: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

10 | WWW.BENTLEY.COM

Import the Data

• All headings from CSV are present, including system generated FID

• Set any WHERE clauses or spatial constraints

• Set any required symbology

• Import the data

Page 11: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

11 | WWW.BENTLEY.COM

Review the Imported Features

• Feature named correctly– <OGRVRTLayer

name="SurveyMon">

• Located at correct location– <GeometryField

encoding="PointFromColumns" x="Easting" y="Northing"/>

• All other properties imported

Page 12: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

12 | WWW.BENTLEY.COM

• <LayerSRS></LayerSRS> specifies the geographic coordinate system (GCS) of the input data

• Examples are:– <LayerSRS>WGS84</LayerSRS>– <LayerSRS>GEOGCS [ "GDA94", DATUM ["Geocentric

Datum of Australia 1994 (EPSG ID 6283)", SPHEROID ["GRS 1980 (EPSG ID 7019)", 6378137.0, 298.257222101]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree",0.0174532925199433]]</LayerSRS>

A Note About Coordinate Systems

Page 13: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

13 | WWW.BENTLEY.COM

A Note About Coordinate Systems

• Because the GCS can be difficult to define, a simple workaround is to omit the GCS definition and import to a DGN to which the GCS of the data has been assigned.

• Reference to other DGN files or reassign GCS

• Sample data is MTM27-10

• Import to DGN file with GCS defined as:

• Reassign GCS as required for transformation

Page 14: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

14 | WWW.BENTLEY.COM

Database and Spreadsheet Sources

• Require an ODBC connection to be setup which is specified in the data source parameter– SrcDataSource>ODBC:SurveyMonXLS</

SrcDataSource>

• Because there can be multiple tables or sheets in each source, an additional parameter is required– <SrcLayer>MonumentData</SrcLayer>

• This defines the table or range name in the source

• All other parameters remain the same

Page 15: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

15 | WWW.BENTLEY.COM

ODBC Example – Excel Spreadsheet

• Setup ODBC link to XLS file

• File must be in Excel 97 – 2003 format

• Data is as shown

• Range Name (MonumentData) defines the extent of the cells to import including the column headers

Page 16: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

16 | WWW.BENTLEY.COM

ODBC Example – Excel Spreadsheet

VRT File

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>ODBC:SurveyMonXLS</SrcDataSource>

<SrcLayer>MonumentData</SrcLayer>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Page 17: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

17 | WWW.BENTLEY.COM

ODBC Example – Access Database

• Setup ODBC link to MDB or ACCDB file

• Data table is as shown

• Source layer is the name of the table

Page 18: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

18 | WWW.BENTLEY.COM

ODBC Example – Access Database

VRT File

<OGRVRTDataSource>

<OGRVRTLayer name="SurveyMon">

<SrcDataSource>ODBC:SurveyMonMDB</SrcDataSource>

<SrcLayer>SurveyMon</SrcLayer>

<GeometryType>wkbPoint</GeometryType>

<LayerSRS></LayerSRS>

<GeometryField encoding="PointFromColumns" x="Easting" y="Northing"/>

</OGRVRTLayer>

</OGRVRTDataSource>

Page 19: Using VRT Files to Import ODBC, CSV

© 2

011

Bent

ley

Syst

ems,

Inco

rpor

ated

19 | WWW.BENTLEY.COM

• Require a custom format for the data• Geometry type is

– <GeometryType>wkbLineString</GeometryType>– <GeometryType>wkbPolygon</GeometryType>

• For more information and examples:

Linear and Polygon Sources

http://communities.bentley.com/products/geospatial/desktop/f/5924/t/65028.aspx