Rational
Convert a CSV of site / sample names, latitudes and longitudes into shapefile elements with a buffer that can be visualised on a map and used for analysis.
Input Files
- CSV (Comma Separated Values) file of sites
- Must include column headers:
id
,lat
andlon
id
: Unique individual nameslat
: Latitudes in decimal format e.g. -32.330703-
lon
: Longitudes in decimal format e.g. 115.912857 - Can include any other columns
Scripts Used
Individual Grouping
group-by-radius.py
melt-alt-map.py
Steps
1. Assigning Groups to Collection Sites
python group-by-radius.py '/path/to/sample_info.csv' 5 group_output.csv
Arguments
- Path to your CSV with samples, latitudes, and longitudes
- Number (in Km) representing how close sites have to be for assignment into a group
- Output CSV name of samples and which group they are assigned to
Outputs
- CSV of samples and which groups they were assigned to (
group_output.csv
) - HTML map of collection sites coloured according to assigned group (
map.html
)
2. Creating Shapefiles from Groups
python melt-alt-map.py group_output.csv 2.5
Arguments
- Path to your CSV with grouped samples from the previous step (
group_output.csv
) - Number (in Km) representing buffer distance around groups to make shapefile polygons, this should be half or less than your grouping distance unless you want to overlap group polygons
Outputs
- Shape file of groups (
output_shapes.shp
) - This will also output other files including
.cpg
,.dbf
,.prj
, and.shx
. Keep these in the same directory as the.shp
if moving them. - HTML map of shapefiles (
output_map.html
)