Last active
December 17, 2015 22:33
-
-
Save jwass/e958227fa34145dd29a5 to your computer and use it in GitHub Desktop.
Example script using Pandas/GeoPandas to help @jqtrde. See https://gist.github.com/jacquestardie/ba32c3304bbe7d8e85b5
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
import pandas as pd | |
import geopandas as gpd | |
import fiona.crs | |
from shapely.geometry import Point | |
# Open the file as a table. Name the two columns as x and y | |
df = pd.read_csv('raw.txt', header=None, names=['x', 'y'], sep=' ') | |
# Convert to shapely Points and to a GeoDataFrame with epsg 26919 | |
geoms = df.apply(lambda row: Point(row['x'], row['y']), axis=1) | |
gdf = gpd.GeoDataFrame({'geometry': geoms}, crs=fiona.crs.from_epsg(26919)) | |
# Convert to lon/lat | |
gdf.to_crs(epsg=4326, inplace=True) | |
# Store GeoJSON | |
with open('converted.geojson', 'w') as f: | |
f.write(gdf.to_json()) |
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
613105 4975798 | |
612517 4975332 | |
618438 4976478 | |
618116 4976792 | |
612186 4974863 | |
607978 4982238 | |
617011 4980265 | |
617490 4980715 | |
573541 4965659 | |
570290 4977544 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment