Closed MuellerMatthew closed 9 years ago
@MuellerMatthew FYI the GeoJSON authors have identified CRS other than CRS84 (WGS 84) as a data sharing anti-pattern and GeoJSON CRS is NOT RECOMMENDED in the latest GeoJSON revision: https://www.ietf.org/rfcdiff?url1=draft-butler-geojson-03&difftype=--html&submit=Go!&url2=draft-butler-geojson-04.
From what I can tell, that is only a proposed change to the standards(and thus still subject to revisions), and it is not the actual GeoJSON standard.
I'm cool with supporting this as an option, despite GeoJSON's eventual removal of it.
That said:
index.js
rather than csv2geojson.js
, the latter is a built file.Alright. Thanks for the feedback. I will make the changes and resubmit the pull request.
The changes allow a Coordinate Reference System (CRS) name to be passed as an option to be used when converting a csv2geojson. The CRS name is then included when creating the new GeoJSON file which may not be using lat/long data, but instead might be using a custom x/y coordinate system, or alternative spatial model. This allows this leaflet plug-in to work with Proj4-leaflet in projecting custom coordinate csv data onto a map.
Example Code(using Proj4Leaflet to display custom coordinates used in GeoJSON):
var CSVLayer = new L.Proj.geoJson(null); // initialize blank layer
csv2geojson.csv2geojson('test.csv', { lonfield: 'y', latfield: 'x', crs: 'urn:ogc:def:crs:EPSG::2263' //Passing the NY Long Island State Plane Coordinate System name to be used in the GeoJSON. },CSVLayer) .addTo(map); //Adding new point layer to map. //Note: you will need to define the coordinate system before you can project it.
This will then convert:
x,y,name 990629.0, 207012.0,"Point 1" 980233.0, 205015.0,"Point 2"
into:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "name": "Point 1" }, "geometry": { "type": "Point", "coordinates": [ 990629, 207012 ] }, "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2263" } } }, { "type": "Feature", "properties": { "name": "Point 2" }, "geometry": { "type": "Point", "coordinates": [ 980233, 205015 ] }, "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::2263" } } } ] }