Importing CSV File with special spatial reference

1432
4
Jump to solution
03-13-2017 06:06 AM
FlorianCADOZ
Occasional Contributor

Hi everyone,

I have a little problem when trying to import a csv file with wkid 102110 (french projection) but each time, the reference wkid still in 4326. Is it normal to keep this wkid ?

See my code below :

esriLoader.dojoRequire(["esri/basemaps",
"esri/map",
"esri/layers/CSVLayer",
"esri/Color",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"esri/InfoTemplate",
"esri/urlUtils",
"esri/geometry/Extent",
"esri/SpatialReference",
"esri/geometry/Point",
"dojo/domReady!"], (esriBasemaps, Map, CSVLayer, Color, SimpleMarkerSymbol, SimpleRenderer, InfoTemplate, urlUtils, Extent, SpatialReference, Point) => {
esriBasemaps.myservice = {
baseMapLayers: [{url: "http://<myserver>/arcgis/rest/services/<myService/MapServer"}
],
title: "myservice"
};

let map = new Map(this.refs['map'], {
basemap: "myservice",
zoom: 0,
extent: new Extent({
xmax: 1438371.080139373,
xmin: -98371.08013937285,
ymax: 7185000,
ymin: 5975000, spatialReference: {wkid: 102110}
})
});
map.spatialReference = new SpatialReference({wkid: 102110});
map.on("load", () => {

let csv = new CSVLayer(process.env.PUBLIC_URL + "/data/Coor_CO.csv", {
latitudeFieldName: 'X_LIEU',
longitudeFieldName: 'Y_LIEU',
columnDelimiter: ';'

});

let orangeRed = new Color([238, 69, 0, 0.5]); // hex is #ff4500
let marker = new SimpleMarkerSymbol("solid", 15, null, orangeRed);
let renderer = new SimpleRenderer(marker);
csv.setRenderer(renderer);
csv.fullExtent = new Extent({
xmax: 1438371.080139373,
xmin: -98371.08013937285,
ymax: 7185000,
ymin: 5975000, spatialReference: {wkid: 102110}
});
csv.spatialReference.wkid = 102110;
map.addLayer(csv);
});
}
)

thx by advance 😃

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Since your project is not 4326 or 102100 you will have to convert your CSV XY data to WGS-84 Lat Lon values for the CSVLayer to work. I am not aware of a way to do this after you have added the csv to the CSVLayer or a way to do this before the data is loaded client side.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Florian,

   To my knowledge the JS API CSVLayer is for WKID 4236 lat long data. I am not sure is supports using data in other projections.

FlorianCADOZ
Occasional Contributor

Alright, thank you for your answer Robert !

So, my problem right now is to convert the geometries in my csv (the csv I'm trying to import) from 102110 to 4326 ! Do you think is it possible to use lngLatToXY(long, lat) or geographicToWebMercator(geometry) while importing my csv with new CSVLayer() ?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Since your project is not 4326 or 102100 you will have to convert your CSV XY data to WGS-84 Lat Lon values for the CSVLayer to work. I am not aware of a way to do this after you have added the csv to the CSVLayer or a way to do this before the data is loaded client side.

FlorianCADOZ
Occasional Contributor

Alright, thank you Robert, I will try to use the WGS84 projection in my map and modify the proj of my data before using it ! It will be more simple ! Thank you for your advice ! 😃

0 Kudos