pyprecag.vector_ops

pyprecag.vector_ops.calculate_area_length_in_metres(in_filename, dissolve_overlap=True)[source]

Calculate the total Area and Length in metres for an input polygon file.

If the input file is geographic, then the feature will be ‘projected’ into wgs84 utm system

Currently there is no Summarize by Column or update existing features .. implemented (see TODO).

Parameters:
  • in_filename (str) – Input polygon file.
  • dissolve_overlap (bool) – Return values after Dissolve ALL geometries.
Returns:

The Total Area and Length

Return type:

list[area,length]

pyprecag.vector_ops.explode_multi_part_features(in_shapefilename, out_shapefilename)[source]

Convert Multipart Vector Features to Single Part Features.

Parameters:
  • in_shapefilename (str) – The input vector file, normally a shapefile
  • out_shapefilename (str) – the resulting shapefile

Returns:None

pyprecag.vector_ops.move_or_copy_vector_file(in_filename, out_filename, keepInput=True, overwrite=True)[source]

Move, Rename or Copy a vector file from one name/location to another.

This uses the GDAL CopyDataSource and DeleteDataSource methods. To Move/Rename - keepInput=False. It will copy the file to new location then delete original. To Copy - keepInput=True.

Parameters:
  • in_filename (str) – The Input filename
  • out_filename (str) – The output filename and location
  • keepInput (bool) – if False will mimic a move/rename by copying the file then deleting the input file
  • overwrite (bool) – If output exists it will be overwritten.
pyprecag.vector_ops.thin_point_by_distance(point_geodataframe, point_crs, thin_distance_metres=1.0, out_filename=None)[source]

Thin points by a distance in metres. All points less than the set distance will be removed.

The point_crs must be a Projected Coordinate System

Parameters:
  • point_geodataframe (geopandas.geodataframe.GeoDataFrame) – The input points geodataframe
  • point_crs (pyprecag_crs.crs) – The Projected Spatial Reference System of the point_geodataframe
  • thin_distance_metres (float) – A floating number representing the minimum distance between points
  • out_filename (str) – (Optional) The path and filename to save the result to
Returns:

The thinned geodataframe

Return type:

geopandas.geodataframe.GeoDataFrame

TODO: Replace with scipy.spatial methods which doesn’t rely on the file being correctly sorted.
In depth testing required.