pyprecag.describe

class pyprecag.describe.CsvDescribe(csv_filename)[source]
__init__(csv_filename)[source]

A description of key elements relating to a comma or tab delimited text file.

Parameters:csv_filename (str) – a comma or tab delimited text
describe_file()[source]

Describe a CSV File and set class properties

get_alias_column_names()[source]
get_column_names()[source]
get_column_types()[source]
get_pandas_dataframe_fromfile()[source]
get_shapefile_column_names()[source]
open_pandas_dataframe(**kwargs)[source]
set_pandas_dataframe(pandas_dataframe)[source]
class pyprecag.describe.VectorDescribe(input_data)[source]
__init__(input_data)[source]

Get a description for a vector file

Parameters:input_data (str) – The input file
describeFile()[source]

Describe a vector File and set class properties

get_alias_column_names()[source]
get_column_names()[source]
get_column_types()[source]
get_shapefile_names()[source]
open_geo_dataframe()[source]

Create geopandas from file

pyprecag.describe.get_column_properties(dataframe)[source]
Get a dictionary representing Column Properties for a pandas dataframe or a geopandas geodataframe.
Includes:
alias - removes spaces and replaces unicode chars with a sensible string using unidecode. ie oC to degC shapefile - An ESRI compatible 10 char alpha-numeric (excludes ‘-‘ & ‘_’) column name. type - The fiona compatible column type dtype - The Pandas/Geopandas compatible column type.

At Present it does not store the column width precision etc.

Parameters:dataframe ([pandas.core.frame.DataFrame or geopandas.geodataframe.GeoDataFrame]) –
Returns:Representing properties of a column.
Return type:collections.OrderedDict
TODO: Consider converting to a dictionary class with the get_shapefile_column_names etc
see: https://stackoverflow.com/questions/1305532/convert-python-dict-to-object
pyprecag.describe.get_dataframe_encoding(dataframe)[source]
pyprecag.describe.get_esri_shapefile_schema(inputGeoDataFrame)[source]
Construct an esri compatible schema for use with fiona.
  • remaps to fiona dtypes
  • Adheres to ESRI column naming standards - 10 alpha numeric characters including ‘_’ underscore.
Parameters:inputGeoDataFrame (geopandas.GeoDataframe) –

Returns (dict): A Fiona compatible Dictionary

pyprecag.describe.predictCoordinateColumnNames(column_names)[source]

Get the Longitude/easting and latitude/northing columns from a list of column_names

Parameters:column_names (List[str]) – A list of column names
Returns:[xColumn,yColumn] Best matched column names
Return type:List[str]
pyprecag.describe.save_geopandas_tofile(inputGeoDataFrame, output_filename, overwrite=True, file_encoding='ascii')[source]
Save a geodataframe to file.
  • adds functionality to asses and rename columns to ESRI compatible 10 alpha-numeric characters.
  • Maps lists and boolean column types to string.
Parameters:
  • inputGeoDataFrame (geopandas.geodataframe.GeoDataFrame) – The Geodataframe to save
  • output_filename (str) – The output filename
  • overwrite (bool) – Overwrite Existing file
  • file_encoding (str) – encoding type for output file.