changeset 2:402faa5eab62 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/geopandas commit 28236fa503017adc781fc8e7bee547eeb44182f2
author iuc
date Tue, 18 Nov 2025 22:46:21 +0000
parents fb5081261c10
children
files table2geojson.xml test-data/geolocation_without_header.csv
diffstat 2 files changed, 56 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/table2geojson.xml	Mon Jun 30 09:28:17 2025 +0000
+++ b/table2geojson.xml	Tue Nov 18 22:46:21 2025 +0000
@@ -1,10 +1,10 @@
-<tool id="geopandas_table2geojson" name="Table to GeoJSON" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="24.2" license="MIT">
+<tool id="geopandas_table2geojson" name="Table to GeoJSON" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@" license="MIT">
     <description></description>
     <macros>
         <token name="@TOOL_VERSION@">1.1.1</token>
-        <token name="@VERSION_SUFFIX@">0</token>
+        <token name="@VERSION_SUFFIX@">1</token>
+        <token name="@PROFILE@">24.2</token>
     </macros>
-
     <requirements>
         <requirement type="package" version="@TOOL_VERSION@">geopandas</requirement>
     </requirements>
@@ -16,23 +16,26 @@
 import json
 import pandas as pd
 import geopandas as gpd
-df = pd.read_csv('$infile', encoding="utf-8")
+
+df = pd.read_csv('$infile', encoding="utf-8", sep=None, engine='python', header=None if '$has_header' == "false" else 0)
 
-#set exc = [int($col) - 1 for $col in $exclude_columns]
-#set inc = [int($col) - 1 for $col in $include_columns]
+inc = [int(x)-1 for x in str('$include_columns').split(",") if x.strip().isdigit()] if '$include_columns' and str('$include_columns').lower() != "none" else []
+exc = [int(x)-1 for x in str('$exclude_columns').split(",") if x.strip().isdigit()] if '$exclude_columns' and str('$exclude_columns').lower() != "none" else []
+
 property_df = df
 
-if "$include_columns" != "None":
-    property_df = df.iloc[:, $inc]
+if inc:
+    property_df = df.iloc[:, inc]
+if exc:
+    property_df = property_df.drop(columns=df.columns[exc])
 
-if "$exclude_columns" != "None":
-    property_df = df.drop(columns=df.columns[$exc])
-       
 gdf = gpd.GeoDataFrame(
     property_df,
-    geometry=gpd.points_from_xy(df.iloc[:,$lat_column-1], df.iloc[:,$long_column-1]),
-    crs="$crs",
-    )
+    geometry=gpd.points_from_xy(
+        df.iloc[:, int($lat_column)-1],   
+        df.iloc[:, int($long_column)-1]),
+    crs="$crs"
+)
         
 # drop_id: bool, default: False
 data = json.loads(gdf.to_json())
@@ -43,8 +46,9 @@
     </configfiles>
     <inputs>
         <param name="infile" type="data" format="csv,tabular,tsv" label="The file you want to convert"/>
-        <param name="lat_column" type="data_column" data_ref="infile" use_header_names="true" label="Latitude column"/>
-        <param name="long_column" type="data_column" data_ref="infile" use_header_names="true" label="Longitude column"/>
+        <param name="has_header" type="boolean" truevalue="true" falsevalue="false" label="First row contains column names (header)?" help="Does your input file consists of a header"/>
+        <param name="lat_column" type="integer" value="1" label="Latitude column"/>
+        <param name="long_column" type="integer" value="2" label="Longitude column"/>
         <param name="include_columns" type="data_column" data_ref="infile" use_header_names="true" multiple="true" optional="true"
             label="Include the following columns" help="Either include or exclude columns, by default, all columns will be taken over into the properties field"/>
         <param name="exclude_columns" type="data_column" data_ref="infile" use_header_names="true" multiple="true" optional="true"
@@ -61,6 +65,7 @@
     <tests>
         <test expect_num_outputs="1">
             <param name="infile" value="geolocation.csv"/>
+            <param name="has_header" value="true"/>
             <param name="lat_column" value="1"/>
             <param name="long_column" value="2"/>
             <param name="crs" value="EPSG:3857"/>
@@ -78,7 +83,21 @@
             </output>
         </test>
         <test expect_num_outputs="1">
+            <param name="infile" value="geolocation_without_header.csv"/>
+            <param name="has_header" value="false"/>
+            <param name="lat_column" value="1"/>
+            <param name="long_column" value="2"/>
+            <param name="crs" value="EPSG:3857"/>
+            <output name="outfile">
+                <assert_contents>
+                    <has_json_property_with_text property="type" text="FeatureCollection"/>
+                    <has_n_lines n="371"/>
+                </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
             <param name="infile" value="geolocation.csv"/>
+            <param name="has_header" value="true"/>
             <param name="lat_column" value="1"/>
             <param name="long_column" value="2"/>
             <param name="include_columns" value="3,4"/>
@@ -95,6 +114,7 @@
         </test>
         <test expect_num_outputs="1">
             <param name="infile" value="geolocation.csv"/>
+            <param name="has_header" value="true"/>
             <param name="lat_column" value="1"/>
             <param name="long_column" value="2"/>
             <param name="exclude_columns" value="5"/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/geolocation_without_header.csv	Tue Nov 18 22:46:21 2025 +0000
@@ -0,0 +1,20 @@
+37.7749,-122.4194,2023-01-01T12:00:00Z,10,23
+37.7751,-122.4190,2023-01-01T12:05:00Z,15,23
+37.7753,-122.4185,2023-01-01T12:10:00Z,20,23
+37.7755,-122.4180,2023-01-01T12:15:00Z,25,24
+37.7757,-122.4175,2023-01-01T12:20:00Z,30,25
+37.7759,-122.4170,2023-01-01T12:25:00Z,35,23
+37.7761,-122.4165,2023-01-01T12:30:00Z,40,23
+37.7763,-122.4160,2023-01-01T12:35:00Z,45,23
+37.7765,-122.4155,2023-01-01T12:40:00Z,50,23
+37.7767,-122.4150,2023-01-01T12:45:00Z,55,23
+37.7769,-122.4145,2023-01-01T12:50:00Z,60,23
+37.7771,-122.4140,2023-01-01T12:55:00Z,65,23
+37.7773,-122.4135,2023-01-01T13:00:00Z,70,23
+37.7775,-122.4130,2023-01-01T13:05:00Z,75,23
+37.7777,-122.4125,2023-01-01T13:10:00Z,80,23
+37.7779,-122.4120,2023-01-01T13:15:00Z,85,23
+37.7781,-122.4115,2023-01-01T13:20:00Z,90,23
+37.7783,-122.4110,2023-01-01T13:25:00Z,95,23
+37.7785,-122.4105,2023-01-01T13:30:00Z,100,23
+37.7787,-122.4100,2023-01-01T13:35:00Z,105,23
\ No newline at end of file