mbloch / mapshaper

Tools for editing Shapefile, GeoJSON, TopoJSON and CSV files
http://mapshaper.org
Other
3.66k stars 529 forks source link

Convert EPSG from a csv file #611

Closed 2803media closed 7 months ago

2803media commented 7 months ago

Hi

I have a csv file like that:

SDOM,TYPEQU,LAMBERT_X,LAMBERT_Y
D4,D401,643379.5,6880776
D4,D401,624466.7,6889588
D6,D601,628199.53,6882074.84
D6,D601,629363.2,6882191
D4,D401,654112.4,6892131
D4,D401,654070.9,6892103
D6,D602,657276.6,6878185
D6,D605,655456.1,6877886
D4,D401,655949.8,6878713

As you see the EPSG is Lambert and I want to convert it to wgs84. So do I need to create a JSON, add geometry datas and convert the proj to wgs84 or is there a quicker way to do that? The end format will be CSV so if I can skip the geojson it's better...

Thanks

2803media commented 7 months ago

The easier way was to use ogr2ogr

ogr2ogr -lco GEOMETRY=AS_XY \
    -f CSV \
    -oo X_POSSIBLE_NAMES=LAMBERT_X \
    -oo Y_POSSIBLE_NAMES=LAMBERT_Y \
    -oo KEEP_GEOM_COLUMNS=NO \
    -t_srs EPSG:4326 \
    -s_srs EPSG:2154 bpe2.csv bpe.csv
mbloch commented 7 months ago

In mapshaper, you would have to convert the csv data to points before projecting, like this:

mapshaper bpe.csv \
-points x=LAMBERT_X y=LAMBERT_Y \
-proj init=EPSG:2154 crs=EPSG:4326 \
-each 'LAT=this.y, LON=this.x' \
-o bpe2.csv
2803media commented 7 months ago

A fastest way with mapshaper!!!

thanks for this input Matthew