-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added command arguments: CSV file, output file, CSV columns. Now CSV …
…column order is not fixed but comes from CSV header.
- Loading branch information
Showing
8 changed files
with
2,396 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,21 @@ This python script takes data in csv format and converts to geoJSON format for u | |
|
||
Two sample CSV documents, sample.csv and country_cap_latlon.csv, are included that can be used to show how the utility works. | ||
|
||
The script currently requires that CSV data be in the format specified in the sample data 'sample.csv', however, this could be easily adapted to fit other formats. | ||
By default, the script expects CSV data be in the format specified in the sample data 'sample.csv'. However, you can specify other formats in the program arguments. | ||
|
||
csvToGeoJSON arguments (all optional): | ||
|
||
-h, --help Show this help message and exit | ||
--verbose, --v Show parameters, detailed messages and geoJSON output | ||
--csv CSV Filepath/name of CVS input file | ||
Default: sample.csv | ||
--output OUTPUT Filepath/name of GeoJSON output file | ||
Default: output.geojson | ||
--columns COLUMNS JSON-formatted dictionary that maps CSV column names to | ||
GeoJSON fields. | ||
Default: "{ 'id':'id', 'latitude':'lat', 'longitude':'lon', 'name':'name', 'value':'pop' }" | ||
where each name:value pair is {geoJSON-column}:{CSV-column} | ||
Note: CSV columns don't have to appear in a particular order since the position of the data columns will be determined from their order in the CSV header (first row). | ||
If CSV contains no ID field, specifying 'id':'-auto-' will automatically generate an ID value based on the row # of the CSV. Otherwise, the ID value will be 0. | ||
|
||
Questions and comments to [email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pointid,label,lat,long,GDP | ||
4,Afghanistan,65.216,33.677,250B | ||
8,Albania,20.068,41.143,315B | ||
894,Zambia,26.32,-14.614,114B |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ "type" : "Feature Collection", | ||
{ "features" : [ | ||
{ "type" : "Feature", | ||
"id" : 1, | ||
"geometry" : { | ||
"type" : "Point", | ||
"coordinates" : ["65.216","33.677"] | ||
}, | ||
"properties" : { | ||
"name" : "Afghanistan", | ||
"value" : "250B" | ||
} | ||
}, | ||
{ "type" : "Feature", | ||
"id" : 2, | ||
"geometry" : { | ||
"type" : "Point", | ||
"coordinates" : ["20.068","41.143"] | ||
}, | ||
"properties" : { | ||
"name" : "Albania", | ||
"value" : "315B" | ||
} | ||
}, | ||
{ "type" : "Feature", | ||
"id" : 3, | ||
"geometry" : { | ||
"type" : "Point", | ||
"coordinates" : ["26.32","-14.614"] | ||
}, | ||
"properties" : { | ||
"name" : "Zambia", | ||
"value" : "114B" | ||
} | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.