Masthead

Data Conversions

1. Introductions

Strings of text, like files from a spreadsheet, can contain a variety of data including names, coordinates, dates, and a huge variety of measurements. The problem is we need to "parse" the string to get at the data we are interested in and then "convert" the values we want from strings to the appropriate data type. Values may not be in the correct units we need to we may need to convert them from one unit to another. Below are some examples of different units with examples:

We may also need to convert data from one spatial reference system to another but this requires special software (like ArcGIS) and we'll talk more about it later.

For units, we may need to convert between various; linear measurements (meters, feet, kilometers, miles, etc.), area units (acres, hectares, square miles, etc.), volume measurements (quarts, gallons, liters, etc.). and other types of measurement.

You now know enough about Python to be able to make all the conversions listed above. You'll want to use "find()" to find the characters that separate each element in the strings and then use list indexing to "substring" the elements. You can also use "split()" if the characters that delimit each element are the same. Then you can format output strings as you desire.

 

 

© Copyright 2018 HSU - All rights reserved.