Processing csv data with gdal and friends
Last active
August 29, 2015 14:05
-
-
Save pbogden/213f3335190d9b117004 to your computer and use it in GitHub Desktop.
csv processing
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
a | b | c | LATITUDE | LONGITUDE | |
---|---|---|---|---|---|
1 | 2 | 3 | 48 | -120 | |
4 | 5 | 6 | 30 | -90 |
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
SOURCE_DATA = test.csv | |
CLEAN_DATA = clean.csv | |
GENERATED_FILES = test.json | |
$(GENERATED_FILES): $(CLEAN_DATA) | |
@topojson -x 'LONGITUDE' -y 'LATITUDE' -o $@ $^ | |
test: $(CLEAN_DATA) | |
ogrinfo -ro -al $(CLEAN_DATA) | |
info: $(GENERATED_FILES) | |
@echo "Here's the info..." | |
ogrinfo -ro -so test.vrt | |
ogrinfo -dialect SQLITE -sql 'SELECT LATITUDE FROM clean LIMIT 2 OFFSET 1' -ro -al test.vrt | |
$(CLEAN_DATA): $(SOURCE_DATA) | |
@echo Making $(CLEAN_DATA) | |
@sed 1d $^ > $@ # remove first line = column names (possibly created by ogr2ogr conversion of xlxs | |
clean: | |
-rm $(CLEAN_DATA) |
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 5. in line 1.
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 is the silly line that's causing me a headache | |
a,b,c,LATITUDE,LONGITUDE | |
1,2,3,48,-120 | |
4,5,6,30,-90 |
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
<OGRVRTDataSource> | |
<OGRVRTLayer name="clean"> | |
<SrcDataSource>clean.csv</SrcDataSource> | |
<GeometryType>wkbPoint</GeometryType> | |
<LayerSRS>WGS84</LayerSRS> | |
<GeometryField encoding="PointFromColumns" x="LONGITUDE" y="LATITUDE"/> | |
</OGRVRTLayer> | |
</OGRVRTDataSource> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment