how to create map from given coordinates in d3js - d3.js

So I need to create the map of my country from the coordinates I have so that I can plot some xyz data on it.
I was able to plot the map with the help of Mike Bostock tut http://bost.ocks.org/mike/map/
But when I went through the .json file, the coordinates mentioned are totally different from the coordinates I have. Like Patna(India) has [5812,6567] as coordinates in the json file while actual coordinates are [25,85].
Could anybody guide me how can I use the coordinates with me to plot the map and then display some data on it??
EDIT:
With the help from #user1614080, I was able to understand how coordinates are converted into screen coordinates.
The issue I have is: I want the map of India in a certain way. For that purpose, I would like to use the list of latitude & longitude I have. But I dont know how to convert these lat-longs into topojson/geojson format.
For the time being I did a simple line plot with the lat-long I had. Some of the values from the coordinates.csv I used for the line plot are:
Longitude,Latitude
88.75,21.58
88.33,21.50
88.17,22.08
88.00,21.75
87.58,21.58
87.08,21.42
But I would like to use topojson/geojson for the same. how can I convert the data from "coordinates.csv" into json?

Related

Place dxf entities on mapbox and get coordinates of its like geojson of labs.mapbox.com/labs/dxf2geojson/dist/

Requirement:
I have to read dxf files entities which can be 2D building dimensions or road etc. Then i have to place it over the map and return the coordinates just like labs.mapbox.com export the coordinates as geojson like the data below export by labs.mapbox.
Approch: For now i'm using python 'exdxf' package to read dxf file which return me entities information e.g in case of line it would be start/end points. Then i was thinking to draw those entities over a canvas (not sure) then place it over mapbox and get the coordinates where canvas is place export geojson of it is the final goal.
Required help in: Suggest me the right way to achieve this solution, i am open to choose any framework / language.
Thanks for your time
If you've got a dxf file and want to export it as a geosjon file, using ezdxf python package is good but you have to do a lot of processing the dxf entities and stuff and it takes time to achieve what you want.
I suggest using ogr2ogr since this is a time saving approach. it is a library for working with geospatial data and you can convert data to different formats such as Geojson, shapefile and others.
you can easily convert your dxf file to a geojson file with :
ogr2ogr -f Geojson GEOJSON_FILE_NAME YOUR_DXF_FILE_NAME
I suggest reading the documentation
first to get to know about this library and all the options it gives you for processing the data.

Displaying labels of polygons of a kml file in google earth

I want to have the names of the polygons of kml file, displayed in google earth.
I converted the kml file from a shapefile in qgis. The kml file is loaded normally, i can see the name and the description in the list on the google earth panel. I cannot see it on the map though. How can I visualize the names?
I know that i can create a second kml file with points and have those displayed but I need to have one single file for all.
How could I do that?
Thank you
If you don't want to use a 2nd KML file for the centroid points + labels, then you can take your original KML file, wrap each polygon in a MultiGeometry tag, and add the polygon's centroid Point feature into each MuiltiGeometry. Then you can have the labels on those points, and have them be part of the same file as the polygons. Unfortunately I don't know of any easy way to create such a thing in QGIS, so you're probably left with hand-editing or programatically generating the KML.

Scilab 3d Plot Datatips

I am plotting some data in Scilab as 3d-Scatter plot (Scilab 6).
With the datatip toggle it is able to show some information about each data point: x,y,z value.
I am actually plotting node-values, x,y are the coordinates, z is the damage.
Is it possible to change the output of the datatip? I would like to display a node-label instead of the coordinates using the datatip-function!
Thank you!
Use datatipSetDisplay (cf. examples in help page)
You can set a custom diplay function per "PolyLine" object in your plot, e.g.
t=0:0.1:10;y=sin(t);
function s=mydatatip(h),s="DATATIP",end
plot(t,y)
datatipSetDisplay(gca().children(1).children(1),mydatatip)
Please note, here gca().children(1).children(1) is a handle to the "PolyLine" object of the plot.

Using ONS maps with D3

I'm sorry this is probably a very basic issue, but I just can't seem to figure it out.
I wanted to map some data using D3.js and the map shape I wanted to use is provided by the UK's Office for National Statistics. I managed to get their geojson data to display, but as soon as I try to do anything with scaling, transforms, topojson, I've been a complete failure.
I've been through many, many, different approaches and I think it's something about the map data that is causing the issue. If I open the shape files in Mapshaper it looks perfect. If I export as geo or topojson and re-import, it looks perfect. If I try to run geo2svg on the geojson export it produces a lot of data, but nothing visible. If I try to import the original shape file into mapstarter.com it produces a flat line. And if I put the topojson into the D3 v4 bounding example I end up with a load of random triangles.
So, can someone show me how do you get ONS mapping data such as http://geoportal.statistics.gov.uk/datasets/1bc1e6a77cdd4b3a9a0458b64af1ade4_3 to display in a d3 example such as https://bl.ocks.org/iamkevinv/0a24e9126cd2fa6b283c6f2d774b69a2?
Thanks
The data that you have linked to is projected. Mapshaper supports projected data, but using d3.geoProjection with projected data will result in no data being displayed in most situations. You need to ensure your data is in lat long pairs for proper display with a d3.geoProjection.
Luckily, in Mapshaper you can reproject your data. Copy all the files of the shapefile into mapshaper, and in the console change the projection to wgs84 (unprojecting your data):
proj wgs84
This data is now easily displayed and manipulated using a d3.geoProjection. Here is an example using the data that you referenced. Also a screenshot:
Lastly: It is possible to display projected data as well, but this is much less common.

How store coordinates of boundaries of each zone region in a London tube map .GIF file?

I am trying to:
Generate a KML file that stores the coordinates of each boundary zone region of London tube map.
Store x,y coordinates as key-pair values to store points of each station on each line.
A KML eventually would look like this:
<nameOfLine>
<zoneNumber>
<zoneregionCoords>
<stationName>
<xCoords></xCoords>
<yCoords></yCoords>
</stationName>
</zoneregionCoords>
</zoneNumber>
</nameOfLine>
Is there a tool to trace the region coordinates of mouse movements (read) from the GIF file onto a KML file? Is there a way I can specifiy the element tags at the same time in the KML file?
The whole objective is to generate this KML file with minimal code.
I am going to use Processing after I have generated the KML file, to give visualization for data to be displayed on the London tube map.gif file.
You can use a tool such as Plot Digitizer to record the coordinates of mouse clicks, then process the final coordinate list with another tool to create a KML.
Alternatively you could create an image overlay in Google Earth using that GIF, align it, then use Google Earth to create the points.

Resources