Converting a lat/lon values to a small map - svg

I have a list of coordinates of lat/lon values consisting of cities around the world. I have put together a SVG map of the US which I would like to display the major cities of the world as pins on top of the SVG map. So far I've figured out that the map projection that I am displaying is a Mercator projection of the US so the next step is how can I get the X/Y coordinates for that map of the map for each city? Once I get the mercator projection from the lat/lon then how is that converted to X/Y values and then to relative X/Y values based on the size of my map?

The Wikipedia article on the Mercator projection provides the equations you need to implement. The Mercator projection transforms lat/long to x/y, that's what map projections do. All you have to do once you have the x/y values is translate them into (in your case) pixels or whatever measure you use.

Related

How to divide a geospatial area into half way points of many lat/lngs

I would like to figure out a way to divide a map into polygons based on the half way positions of lat/long positions.
For example, if there are four lat/long positions on a map (titled "unknown Placemarkers" in the image), I'd like to create four polygons which represent the half way points between the four lat/long positiongs (shown as a yellow line in the image)
Similarly if there were three lat/long positions then the polygons would adjust to have areas which are split by the half way point between the three points.
And the final scenario is that if a lat/lng is surrounded by other polygons the polygon split would be fully enclosed according to the last image.

Combine intersecting polygons in QGIS

I've created a new file of intersecting polygons (20 metre buffer of points). I would like to combine the polygons using QGIS, but not to combine them into one layer, with one single attribute table entry if you see what I mean - in order to reduce the number of single polygons in the layer. I've created an attribute field in the table for each polygon as ROWID. I would then like to output the centroid co-ordinates of each combined polygon (eastings & northings) using QGIS.

Cartesian to Latitude/Longitude

I have a 3D model of a 10km x 10km topographic map which I've imported from sketch-up , the model is just a bunch of X,Y,Z points (where X+ is the north and Z+ is straight up, perpendicular to the ground)
I know the Latitude Longitude values of the (0,0,0) point. So given a X,Y,Z point how do I get its Latitude Longitude values?
I need to be pretty accurate so you can't assume the earth is a perfect sphere (you can however assume it's an ellipsoid)
For best accuracy you need to know what map projection the map was drawn in. You should be able to find that out from the map. For example in the UK the Ordnance Survey maps use the OSGB36 datum, and the projection is Transverse mercator. The projection tells you how to convert geographic (lat,long for the datum ellipsoid) coordinates to map coordinates (easting and northing) and how to do the reverse calculation, which is pretty much what you want.
If you don't know the projection, the next best thing would be if you could find out -- again from the map, they are often written on it -- the scale-factor and convergence of the projection at some points on the map. The point is that there is usually a slowly spatially varying difference between map north (the direction the north axis points in) and true north (the direction of the north pole from a point, the direction of the latitude axis) and there is always a slowly spatiallty varying scale factor, the ratio of a distance in map coordinates and the true distance. Note that this not the same thing as the scale of the printed map (an inch to a mile or whatever), it is a property of the projection.
Over a 10km square, it would be reasonably accurate to treat both the scale and convergence as constants. Then given an x,y point you compute the map bearing from 0,0 using
b = atan2(x,y)
and convert this to a true bearing by subtracting the convergence.
You also compute the map distance by
r = hypot(x,y)*S
where S is the scale of the map, e.g. if your a change of 1 in x coordinates represents a distance of 100m, S is 100
and convert r to a true distance by dividing by the scale-factor.
Finally you want to compute the lat,long a given distance and bearing from a given point (the lat,long of 0,0). An accurate way to do this is to use Vincenty's formulae.
One thing to note here is that the scale and convergence, if quoted on the map will be relative to the ellipoid used in construction of the map, so you will be computing lat,long coordinates for that ellipsoid.

In Geocouch, how can I get all objects by lon/lat coordinates?

I.e. all objects that contain this coordinates (for polygons) or cross them (for lines)?
You can collapse the bounding box you query with to a point.

Finding a point clicked in a grid

Given this grid ( http://i.stack.imgur.com/Nz39I.jpg is a trapezium/trapezoid, not a square), how do you find the point clicked by the user? I.e. When the user clicks a point in the grid, it should return the coordinates like A1 or D5.
I am trying to write pseudo code for this and I am stuck. Can anyone help me? Thanks!
EDIT: I am still stuck... Does anyone know of any way to find the height of the grid?
If it is a true perspective projection, you can run the click-point through the inverse projection to find it's X,Z coordinates in the 3D world. That grid has regular spacing and you can use simple math to get the A1,D5,etc.
If it's just something you drew, then you'll have to compare the Y coordinates to the positions of the horizontal lines to figure out which row. Then you'll need to check its position (left/right) relative to the angled lines to get the column - for that, you'll need either coordinates of the end-points, or equations for the lines.
Yet another option is to store an identical image where each "square" is flood-filled with a different color. You then check the color of the pixel where the user clicked but in this alternate image. This method assumes that it's a fixed image and is the least flexible.
If you have the coordinates of end points of the grid lines then
Try using the inside-outside test for each grid line and find the position
Since this grid is just a 3D view of a 2D grid plane, there is a projective transform that transforms the coordinates on the grid into coordinates on the 2D plane. To find this transform, it is sufficient to mark 4 different points on the plane (say, the edges), assign them coordinates on the 2D plane and solve the resulting linear equation system.

Resources